I use some libraries/modules for my project.
On two of the libraries there are "nineoldandroids" used in the gradle with "-compile 'com.nineoldandroids:library:2.4.0'" on every library/module !
If I want to crate an APK in Android Studio with "Build - Generate Signed APK" I get always the "ProGuard" error "duplicateclasses" with following error:
Error:Execution failed for task ':xxxxx:proguardRelease'.
> java.io.IOException: Can't write
[F:\Projekte\Android_Studio\xxxx\build\intermediates\classes-proguard\
release\classes.jar] (Can't read
[F:\Projekte\Android_Studio\xxxx\build\intermediates\exploded-aar\
Android_Studio\library_SwipeListView\unspecified\libs\
nineoldandroids-2.4.0.jar(;;;;;;!META-INF/MANIFEST.MF)]
(Duplicate zip entry [com/b/a/b.class == nineoldandroids-2.4.0.jar:com
/nineoldandroids/animation/Animator$AnimatorListener.class]))
How can I solve this error?
SwipeListView:
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.nineoldandroids:library:2.4.0'
}
NumberPickerCompat:
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
}
MainProject:
dependencies {
compile project(':library_CalendarViewCompbat')
compile project(':library_FAB_Menu')
compile project(':library_NumberPickerCompat')
compile project(':library_ReminderDatePicker')
compile project(':library_StickyListHeaders')
compile project(':library_SwipeListView')
compile project(':library_SunDate_Picker')
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:20.0.0'
compile files('libs/crashlytics.jar')
compile files('libs/dashclock-api-r1.1.jar')
compile files('libs/dropbox-android-sdk-1.5.3.jar')
compile files('libs/httpmime-4.0.3.jar')
compile files('libs/json_simple-1.1.jar')
}
You can exclude one of the nineoldandroids transitive dependencies from your main project :
dependencies {
compile project(':library_NumberPickerCompat')
compile(project(':library_SwipeListView')) {
// Already present in NumberPickerCompat
exclude group: 'com.nineoldandroids'
}
...
}
Please note the extra parentheses on the second compile dependency
Thanks all for your answers.
The problem was that some .jar files are saved in some "build" folders.
This was because I have migrated from Eclipse with the .jars and have later deleted it and added the compile to gradle.
But I haven't seen that in the "build" folders they are saved too.
Try this:
SwipeListView:
dependencies {
compile 'com.android.support:support-v4:20.0.0'
}
NumberPickerCompat:
dependencies {
}
MainProject:
dependencies {
//put nineoldandroids in main project
compile 'com.nineoldandroids:library:2.4.0'
compile project(':library_CalendarViewCompbat')
compile project(':library_FAB_Menu')
compile project(':library_NumberPickerCompat')
compile project(':library_ReminderDatePicker')
compile project(':library_StickyListHeaders')
compile project(':library_SwipeListView')
compile project(':library_SunDate_Picker')
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:20.0.0'
compile files('libs/crashlytics.jar')
compile files('libs/dashclock-api-r1.1.jar')
compile files('libs/dropbox-android-sdk-1.5.3.jar')
compile files('libs/httpmime-4.0.3.jar')
compile files('libs/json_simple-1.1.jar')
}
Related
I am running into this issue every time I am trying to run my project.
I am getting this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzpi.class
Here is my build script:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.15.2'
}
}
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/commons-collections4-4.0.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/graphview-3.1.jar')
testCompile 'junit:junit:4.12'
compile project(':progresslibrary')
compile files('libs/gson-2.6.2.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') {
transitive = true;
}
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
compile 'com.android.support:multidex:1.0.0'
compile 'com.hrules:charter:1.4.0'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
//noinspection GradleCompatible
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
compile 'com.android.support:multidex:1.0.0'
compile 'com.hrules:charter:1.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.snappydb:snappydb-lib:0.5.2'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.wdullaer:materialdatetimepicker:2.2.0'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.shamanland:fab:0.0.8'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'org.jsoup:jsoup:1.9.1'
compile 'com.flurry.android:analytics:6.2.0'
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile 'com.github.danielemaddaluno.androidupdatechecker:library:1.0.2'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
android {
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}
apply plugin: 'build-announcements'
please tell me what is wrong with my build script
At a quick glance, I can tell you that the problem exists in Google Play Services. And I am going to guess that these all need to be the same version (grouped by same version here).
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
In order to efficiently do that, you can define an ext block in you Gradle file for keeping the version numbers consistent.
Additional note: This line compile fileTree(include: ['*.jar'], dir: 'libs')... It says compile all JAR files in the libs/ directory, therefore, these lines are pointless, and you can remove them while you try to identify where the error occurs.
compile files('libs/commons-collections4-4.0.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/graphview-3.1.jar')
compile files('libs/gson-2.6.2.jar')
Sample build.gradle
ext {
// Variables to keep libraries consistent
supportLibrary = "23.2.0"
googlePlayServicesVersion = '9.4.0'
// Support Libraries dependencies
supportDependencies = [
design : "com.android.support:design:${supportLibrary}",
recyclerView : "com.android.support:recyclerview-v7:${supportLibrary}",
cardView : "com.android.support:cardview-v7:${supportLibrary}",
appCompatV7 : "com.android.support:appcompat-v7:${supportLibrary}"
]
googlePlayServicesDepends = [
analytics : "com.google.android.gms:play-services-analytics:${googlePlayServicesVersion}"
plus : "com.google.android.gms:play-services-plus:${googlePlayServicesVersion}"
location : "com.google.android.gms:play-services-location:${googlePlayServicesVersion}"
fitness : "com.google.android.gms:play-services-fitness:${googlePlayServicesVersion}"
appindexing : "com.google.android.gms:play-services-appindexing:${googlePlayServicesVersion}"
auth : "com.google.android.gms:play-services-auth:${googlePlayServicesVersion}"
gcm : "com.google.android.gms:play-services-gcm:${googlePlayServicesVersion}"
]
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile supportDependencies.appCompatV7
// compile supportDependencies.recyclerView
// recommended - includes those above
compile supportDependencies.design
// extras
compile supportDependencies.cardView
// The correct Volley library
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile "com.google.code.gson:gson:2.6.2"
// Google Play Services
compile googlePlayServicesDepends.location
// TODO: Add others
}
I am getting below error log:
Error:Execution failed for task
'app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
android/support/annotation/Keep.class
Here is the list of build.gradle dependencies:
dependencies {
compile project(':chartboostSDK')
compile project(':flurry_lib')
compile project(':googleCloudMessaging_lib')
compile project(':mainLibProj')
compile project(':localytics_lib')
compile project(':mobihelp_sdk_android_v1534')
compile project(':unityandroidresources')
compile project(':iAB_lib')
compile project(':etcetera_lib')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/FlurryPlugin.jar')
compile files('libs/FreshdeskPlugin.jar')
compile files('libs/Prime31UnityActivity.jar')
compile files('libs/adcolony-adapter-1.1.6.jar')
compile files('libs/android-bridge.jar')
compile files('libs/apsalar.jar')
compile files('libs/apsalarUnity3d.jar')
compile files('libs/bolts-android-1.2.1.jar')
compile files('libs/chartboost-adapter-1.0.6.jar')
compile files('libs/crittercism_v5_4_3_sdkonly.jar')
compile files('libs/dagger.jar')
compile files('libs/emojiplugin.jar')
compile files('libs/in-app-purchasing-2.0.61.jar')
compile files('libs/javax.inject.jar')
compile files('libs/mediationsdk-6.3.5.jar')
compile files('libs/nativex-adapter-1.0.3.jar')
compile files('libs/nineoldandroids.jar')
compile files('libs/support-annotations-23.1.1.jar')
compile files('libs/tapjoyconnectlibrary.jar')
compile files('libs/tapjoyunitywrapper.jar')
compile files('libs/unity-classes.jar')
compile files('libs/vungle-adapter-1.1.6.jar')
compile files('libs/unity-classes.jar')
}
Try to import the library as a gradle dependency like this:
compile 'com.android.support:support-annotations:23.1.1'
If you want to use jar then it seems like that it hasn't been properly built. So try to do something like this:
Unzip the jar file. (Simply change .jar extension to .zip
This will remove the duplicate files.
Recreate the jar using jar cf xmlbeans.jar -C (path to unzipped folder) . (Mind it, there is a dot in the end of command)
Use this regenerated jar
I am adding code to my project which requires google-api-client, when I add it via the gradle dependency, I get a duplicate error.
Here is the gradle dependency list
dependencies {
compile 'com.adobe.creativesdk:image:4.0.0'
// compile project(':showcaseView')
compile project(':facebook')
compile project(':SwipeMenuListView')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:22.2.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:7.5.+'
compile 'com.google.android.gms:play-services-appinvite:7.5.0'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.3.3'
compile 'commons-codec:commons-codec:1.9'
compile 'commons-io:commons-io:2.4'
compile 'com.google.gdata:core:1.47.1'
compile files('libs/tape-1.1.0.jar')
compile files('libs/gdata-photos-meta-2.0.jar')
compile 'com.google.api-client:google-api-client:1.20.0'
// compile 'com.google.http-client:google-http-client:1.20.0'
// compile files('libs/android-oauth-client-0.4.5.jar')
}
Here is the error that I receive
Execution failed for task ':FloomIt:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/common/collect/package-info.class
If I remove the google-api-client line from the dependency list, the error goes away.
Any suggestions on how to proceed?
That is because com.google.api-client:google-api-client depends on com.google.guava:guava-jdk5 but com.google.gdata:core depends on com.google.guava:guava. The JDK5 split is unfortunate.
Gradle allows you to override dependencies. Try replacing the gdata dependency with something like:
compile('com.google.gdata:core:1.47.1') {
exclude group: 'com.google.guava', module: 'guava'
}
I have add spinnerwheel module into my project and it wouldn't build anymore. It has some kind of a duplicate entry with nineoldandroids library Which is included in spinnerwheel module . I get this error during the build
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/nineoldandroids/util/FloatProperty.class
I ran ../gradlew dependencies on the app folder and this is what i found under spinnerwheel module:
\--- *********-android3.5:spinnerwheel:unspecified
\--- LOCAL: nineoldandroids-2.2.0.jar
This is my build.gradle file :
dependencies {
compile 'com.android.support:appcompat-v7:22.0.+'
compile 'com.android.support:support-v4:22.+'
//noinspection GradleCompatible
compile 'com.android.support:multidex:1.0.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:3.23.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.apache.httpcomponents:httpmime:4.3.5'
compile 'org.apache.httpcomponents:httpclient:4.3.5'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.1'
compile project(':loopj')
compile project(':StackBlur')
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
compile 'com.navercorp.pulltorefresh:library:3.2.0#aar'
compile 'com.edmodo:cropper:1.0.1'
compile 'com.getbase:floatingactionbutton:1.7.0'
compile 'com.afollestad:material-dialogs:0.6.6.3'
compile 'com.sothree.slidinguppanel:library:3.0.0'
compile 'com.github.traex.rippleeffect:library:1.2.3'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.11'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.github.johnpersano:supertoasts:1.3.4#aar'
compile 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.4#aar') {
transitive = true;
}
compile 'io.branch.sdk.android:library:1.5.5'
compile 'com.kyleduo.switchbutton:library:1.2.8'
}
just Add this compile 'compile 'com.nineoldandroids:library:2.4.0' in your gradle section And update minifyEnabled false instead minifyEnabled true Like
Can't figure out why I keep getting this error why trying to run application (it compiles fine)
com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/googleapis/GoogleUtils;
From the stack trace above I can say it stopped at:
/Users/jacek/Documents/GoW/myapp/build/pre-dexed/debug/support-v4-19.1.0-d45e513079f821d0bdcba2b3c444c8362d798113.jar
I think the next library it was going to generate was a dupplicate, but hard to say what was it...
Here are my dependencies:
dependencies {
compile project(':pixlUI')
compile project(':gowEndpoint')
compile project(':messageEndpoint')
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.android.support:appcompat-v7:19.1.+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.jakewharton:butterknife:4.0.1'
compile 'joda-time:joda-time:2.1'
compile 'commons-lang:commons-lang:2.4'
compile 'commons-io:commons-io:2.4'
compile files('libs/google-api-client-1.16.0-rc.jar')
compile files('libs/google-api-client-android-1.16.0-rc.jar')
compile files('libs/google-http-client-1.16.0-rc.jar')
compile files('libs/google-http-client-android-1.16.0-rc.jar')
compile files('libs/google-http-client-gson-1.16.0-rc.jar')
compile files('libs/google-http-client-jackson-1.16.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.16.0-rc.jar')
compile files('libs/google-oauth-client-1.16.0-rc.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jackson-core-asl-1.9.11.jar')
compile files('libs/jsr305-1.3.9.jar')
}
After some try-error I figured out that
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jackson-core-asl-1.9.11.jar')
were dupplicates