I'm using android studio. I'm developing an app with google cloud appengine (endpoints) and google cloud storage. When I write the gradle dependencies as shown:
dependencies {
compile 'com.google.apis:google-api-services-storage:v1beta2-rev77-1.20.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:multidex:1.0.1'
compile project(path: ':backend', configuration: 'android-endpoints')
compile files('libs/joda-time-2.8.2.jar')
compile ('com.google.appengine.tools:appengine-gcs-client:0.4.4')
compile files('libs/guava-18.0.jar')
}
I retrieve an error when compiling:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/google/common/reflect/TypeToken$TypeCollector$ForwardingTypeCollector.class
I've tried to exclue in this way
compile ('com.google.appengine.tools:appengine-gcs-client:0.4.4'){
exclude group: 'com.google.guava'
}
But nothing works. Can anybody help me?
1) First of all let's remove this ugly jars from your dependencies. I am about joda-time and guava
compile 'joda-time:joda-time:2.8.2'
compile 'com.google.guava:guava:18.0'
2) Move exclude group: 'com.google.guava' from appengine to apis
compile ('com.google.apis:google-api-services-storage:v1beta2-rev77-1.20.0') {
exclude group: 'com.google.guava'
}
And add it to your :backend
compile (project(path: ':backend', configuration: 'android-endpoints')) {
exclude group: 'com.google.guava'
}
3) Now you can get this error com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '...java'' finished with non-zero exit value 1
If yes we should add exclude to appengine
compile('com.google.appengine.tools:appengine-gcs-client:0.4.4') {
exclude group: 'javax.transaction'
}
4) Now you get Duplicate files copied in APK META-INF/NOTICE.txt
And this we solve with packagingOptions in android {} section
packagingOptions {
exclude 'META-INF/NOTICE.txt'
}
So your final result
android {
...
packagingOptions {
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile (project(path: ':backend', configuration: 'android-endpoints')) {
exclude group: 'com.google.guava'
}
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'joda-time:joda-time:2.8.2'
compile 'com.google.guava:guava:18.0'
compile ('com.google.apis:google-api-services-storage:v1beta2-rev77-1.20.0') {
exclude group: 'com.google.guava'
}
compile('com.google.appengine.tools:appengine-gcs-client:0.4.4') {
exclude group: 'javax.transaction'
}
}
Related
I compile my proeject with react-native-camera and another libs to android.
when I try to compile my project in release with this code:
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
exclude group: "com.android.support"
}
and I receive this error:
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/facebook/infer/annotation/Assertions.class
so I try to compile add infe-anotation to not compile
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
exclude group: "com.android.support"
exclude group: "com.facebook.infer.annotation"
}
compile to release but not run the app.
I am getting this error
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException:
duplicate entry: org/intellij/lang/annotations/Identifier.class
It started after I added compile "com.wefika:flowlayout:0.4.0" to my gradle
This is my gradle file
packagingOptions {
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by #Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
dexOptions {
javaMaxHeapSize "4g"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile "com.google.firebase:firebase-messaging:9.0.0"
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'com.google.android.gms:play-services-plus:9.6.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-core:9.4.0'
compile "com.wefika:flowlayout:0.4.0"
configurations.all {
resolutionStrategy {
force 'com.android.support:design:23.4.0'
force 'com.android.support:support-v4:23.4.0'
force 'com.android.support:appcompat-v7:23.4.0'
}
}
See this issue here, the comments provide the solution
https://github.com/blazsolar/FlowLayout/issues/31
Basically, you need to change the dependency to look like:
compile ("com.wefika:flowlayout:<version>") {
exclude group: 'com.intellij', module: 'annotations'
}
Conflict with it:
compile 'org.jetbrains:annotations-java5:15.0'
Because it contains the same annotations as kotlin
In my case, I remove it and fix.
Hope it can help you.
I am facing, Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/annotation/AttrRes.class
build.gradle file (main project)
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-location:7.8.0'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-nearby:7.8.0'
compile ('com.android.support:recyclerview-v7:+') {
exclude module: 'support-v4'
}
compile 'com.firebase:firebase-client-android:2.3.1+'
compile ('com.android.support:cardview-v7:22.0.+') {
exclude module: 'support-v4'
}
compile ('com.squareup.okhttp:okhttp:2.4.0') {
exclude module: 'support-v4'
}
compile ('com.squareup.picasso:picasso:2.5.2') {
exclude module: 'support-v4'
}
compile ('com.squareup.retrofit:retrofit:2.0.0-beta1') {
exclude module: 'support-v4'
}
compile('com.squareup.retrofit:converter-gson:2.0.0-beta1') {
exclude module: 'gson'
}
compile('com.segment.analytics.android:all:2.5.1#aar') {
transitive = true
exclude module: 'support-v4'
}
compile ('com.android.support:design:22.2.0') {
exclude module: 'support-v4'
}
compile('com.uservoice:uservoice-android-sdk:1.2.+') {
exclude module: 'commons-logging'
exclude module: 'httpcore'
exclude module: 'httpclient'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile project(':contactsChipView')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile project(':facebook-android-sdk-4.0.1')
compile ('com.android.support:multidex:1.0.0'){
exclude module: 'support-v4'
}
Files in /libs directory (main project):
gson-2.2.3.jar
Parse-1.9.2.jar
YoutubeAnddroidPlayerApi.jar
Files in /libs directory (facebook module):
android-support-v4.jar
bolts.jar
As you can see the above gradle file, I have tried adding exclude for almost all dependencies. But still, no luck.
I also tried changing build tools from 22.0.1 to 22.0.0, even this didn't work.
I went through other posts, but no luck.
Anybody knows how to solve this?
I have an old eclipse based project , and i converted it to android studio based. The convertion success, but i have problem when adding other dependency, first i get error java.exe finished with non-zero exit value 2, because of duplicate dependency support v4, and i try to exlude modul support v4, but now im getting java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
this is my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SlidingMenu')
compile project(':PhotoView')
compile project(':viewpager')
compile project(':StackBlur')
compile project(':FacebookSDK')
compile files('libs/LibAllShareInterface_2.0.0.jar')
// Exclude module support-v4 to remove duplicate
compile ('com.android.support:appcompat-v7:22.2.0') { exclude module: 'support-v4' }
compile('com.android.support:design:22.2.0') { exclude module: 'support-v4' }
compile('com.squareup.picasso:picasso:2.5.2') { exclude module: 'support-v4' }
compile('com.android.support:recyclerview-v7:21.0.0') { exclude module: 'support-v4' }
compile('com.android.support:cardview-v7:22.2.0') { exclude module: 'support-v4' }
compile('com.android.support:support-annotations:22.2.0') { exclude module: 'support-v4' }
}
Any help will be appreciated
Well although I am not gradle expert and I'm experiencing some problems myself, I was able to reproduce an error complaining about appcompat-v4, using your dependencies.
It seems that you are completely excluding support-v4 from all your dependencies, and since support-v4 is required, you must either specify it as a dependency separately, or change this:
compile ('com.android.support:appcompat-v7:22.2.0') { exclude module: 'support-v4' }
to this:
compile ('com.android.support:appcompat-v7:22.2.0')
so you don't exclude support-v4 completely from your project.
I did the second and the project could build (A sample project with just those dependencies defined).
If:
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.3'
compile 'de.greenrobot:eventbus:2.2.0'
compile 'com.intellij:annotations:+#jar'
compile 'com.jpardogo.googleprogressbar:library:1.0.0'
compile project(':floatlabel')
compile project(':Android-SwipeToDismiss')
compile project(':Android-UndoBar') {
exclude group: 'com.nineoldandroids', module: 'library' // without or without this one
}
compile project(':AndroidSlidingUpPanel:library') {
exclude group: 'com.nineoldandroids', module: 'library' // without or without this one
}
}
I receive this error message:
Gradle 'mProject' project refresh failed: Build script error, unsupported Gradle DSL method found: 'exclude()'!
But this works:
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.3'
compile 'de.greenrobot:eventbus:2.2.0'
compile 'com.intellij:annotations:+#jar'
compile 'com.jpardogo.googleprogressbar:library:1.0.0'
compile project(':floatlabel')
compile project(':Android-SwipeToDismiss')
compile project(':Android-UndoBar')
compile project(':AndroidSlidingUpPanel:library')
}
configurations {
all*.exclude group: 'com.nineoldandroids', module: 'library'
}
Trying to understand why, please clarify!
Use
compile (project(':Android-UndoBar')) {
exclude group: 'com.nineoldandroids', module: 'library' // without or without this one
}
So with extra parentheses.