7

Immediately after adding the facebook-audience-network-sdk in my gradle file, I started getting errors, the first one I fixed my adding multiDexEnabled true, after that I keep getting this error

Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

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

Here are my dependencies list in build.gradle

 dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:23.1.1'
   compile 'com.mcxiaoke.volley:library:1.0.17'
   compile 'com.android.support:recyclerview-v7:23.1.1'
   compile 'com.android.support:design:23.1.1'

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

   compile 'com.facebook.android:facebook-android-sdk:4.10.0'
   compile 'com.facebook.android:audience-network-sdk:4.10.0'
   compile 'joda-time:joda-time:2.7'
 }

After running gradle with -q dependencies here is my screenshot, I think the problem is related to google play services libraries seeing the facebook.android:audience-network-sdk depends on analytics 7.8.0 while I have included the latest 8.4.0 already in my dependencies, I'm not sure. How can i fix this? enter image description here

4
  • play-services-base:7.8.0 and 8.4.0 are likely conflicting Feb 12, 2016 at 3:50
  • Also, 4.10.0 are the latest versions for both the facebook sdks. (If you wanted them) Feb 12, 2016 at 3:54
  • @cricket_007 I have updated to the latest sdk, I see it still depends on google play services 8.1.0 while I'm compiling on 8.4.0. Still the same error, still trying to fix the issue. Feb 12, 2016 at 4:16
  • Just googling "ZipException: duplicate entry" comes up with several hits, but it basically comes down to excluding parts of one library from gradle Feb 12, 2016 at 4:17

1 Answer 1

13

I finally got rid of the error. So the problem was with the com.google.android.gms:play-services-ads-8.1.0. You can see from the image it was 8.1.0 and other play dependencies were 8.4.0.

So these two ways worked. One was to change the dependency into

 compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
    exclude group:"com.google.android.gms"
 }

But the issue with this is that, it could be a problem since in my other dependencies I didn't have play-services-ads:8.4.0'

So the way I solved this was just add a single line

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

This way everything worked perfectly, because when gradle compiled it automatically replaced the 8.1.0 into the 8.4.0

Here is my final dependencies list that worked

dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     compile 'com.android.support:appcompat-v7:23.1.1'
     compile 'com.mcxiaoke.volley:library:1.0.17'
     compile 'com.android.support:recyclerview-v7:23.1.1'
     compile 'com.android.support:design:23.1.1'

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

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

     compile 'com.facebook.android:facebook-android-sdk:4.10.0'
     compile 'com.facebook.android:audience-network-sdk:4.10.0'
     compile 'joda-time:joda-time:2.7'

}

3
  • This should work as long as there are no changes in the play-services-ads api from version 8.1.0 to 8.4.0 that would break the facebook sdk.
    – Rohan
    Feb 12, 2016 at 6:31
  • Sure! It works fine, the ads show up, and the clicks are counted. I guess thats the important part Feb 12, 2016 at 6:58
  • @Rohan that is the expected behaviour as you can see on the screenshot Gradle anyway always replace old dependencies with the newer versions. May 17, 2017 at 12:35

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.