Duplicate jar file Error

2019-06-01 01:13发布

问题:

Error

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

    com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class

I added the following dependencies

dependencies {
//compile 'com.google.android.gms:play-services:+'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile files('libs/twitter4j-core-4.0.2.jar')
compile project(':devsmartAndroid')
compile project(':FacebookSDK')
compile project(':libPhotoView')
compile files('libs/android-support-v4.jar')
compile project(':library')
//compile 'com.google.android.gms:play-services-gcm:7.5.0'
//compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile files('libs/gcm.jar')
compile files('libs/libGoogleAnalyticsServices.jar')  }

回答1:

:app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command.class

Problem is here

 compile 'com.google.android.gms:play-services:8.4.0'
 compile 'com.google.android.gms:play-services-location:8.3.0'

You should call one Finally

compile 'com.google.android.gms:play-services:8.4.0'

Edit

I assume libGoogleAnalyticsServices.jar creating Duplicate entry .

So you can comment just this jar

compile files('libs/libGoogleAnalyticsServices.jar')



回答2:

In your Gradle file there are two dependencies

compile 'com.google.android.gms:play-services:8.4.0'

compile 'com.google.android.gms:play-services-location:8.3.0'

Instead of using both use only one

compile 'com.google.android.gms:play-services:8.4.0'

Because the play-services package is consolidated with all play services. otherwise add separately each one such as GCM,GA,etc