包含facebook sdk后的Gradle错误 [英] Gradle error after including facebook sdk

查看:198
本文介绍了包含facebook sdk后的Gradle错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

立即在我的gradle文件中添加facebook-audience-network-sdk之后,我开始发现错误,第一个修复了我添加multiDexEnabled true的错误,之后,我一直收到此错误。



任务执行失败':app:transformClassesWithJarMergingForDebug'。


com.android.build.api.transform.TransformException :java.util.zip.ZipException:重复条目:com / google / android / gms / internal / zzqa.class

我在build.gradle中的依赖项列表

 依赖项{
编译fileTree(dir:'libs',include:[' * .jar'])
testCompile'junit:junit:4.12'
compile'c​​om.android.support:appcompat-v7:23.1.1'
compile'c​​om.mcxiaoke.volley: library:1.0.17'
compile'c​​om.android.support:recyclerview-v7:23.1.1'
compile'c​​om.android.support:design:23.1.1'

编译'com.google.android.gms:play- services-gcm:8.4.0'
compile'c​​om.google.android.gms:play-services-auth:8.4.0'
compile'c​​om.google.android.gms:play-services- analytics:8.4.0'

compile'c​​om.facebook.android:facebook-android-sdk:4.10.0'
compile'c​​om.facebook.android:audience-network-sdk: 4.10.0'
compile'joda-time:joda-time:2.7'
}

使用-q依赖关系运行gradle后,这里是我的屏幕截图,我认为问题与google play服务库有关,看到facebook.android:audience-network-sdk取决于分析7.8.0,而我已将最新8.4.0已经在我的依赖中,我不确定。
我该如何解决这个问题?

解决方案

我终于摆脱了错误。所以问题出在com.google.android.gms:play-services-ads-8.1.0。你可以从图像中看到它是8.1.0,其他播放依赖项是8.4.0。



所以这两种方法都有效。一个是将依赖项改为

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



<但是问题在于,这可能是一个问题,因为在我的其他依赖项中,我没有play-services-ads:8.4.0'



所以我解决这个问题的方法只是添加一行代码。

  compile'c​​om.google.android.gms:play-services- ads:8.4.0'

这种方式一切都很完美,因为当gradle编译它时会自动替换8.1 .0到8.4.0中

这是我的最终依赖列表,它工作

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

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

compile'c​​om.google.android.gms:play-services-ads:8.4.0'

compile'c​​om.facebook.android:facebook-android-sdk:4.10.0'
compile'c​​om.facebook.android:audience-network-sdk:4.10.0'
compile'joda -time:joda-time:2.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?

解决方案

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'

}

这篇关于包含facebook sdk后的Gradle错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆