尝试添加包时出现错误“重复条目:com/google/android/gms/internal/zzble.class”
Posted
技术标签:
【中文标题】尝试添加包时出现错误“重复条目:com/google/android/gms/internal/zzble.class”【英文标题】:Getting the error "duplicate entry: com/google/android/gms/internal/zzble.class" when trying to add a package 【发布时间】:2017-07-23 15:14:57 【问题描述】:我正在尝试将 react-native-firestack
包添加到我的应用程序中。但它不断给出以下错误:
:app:mergeDebugResources UP-TO-DATE
:app:recordFilesBeforeBundleCommandDebug
:app:bundleDebugJsAndAssets SKIPPED
:app:generateBundledResourcesHashDebug
4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithJarMergingForDebug FAILED
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/internal/zzble.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.498 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment.
Go to https://facebook.github.io/react-native/docs/getting-started.html
and check the Android tab for setup instructions.
我尝试在几个包中添加一些包到exclude group
。但没有一个奏效。这是./gradlew clean :app:dependencies
结果:https://gist.github.com/THPubs/8fe8b4b9c80e3c6cd49541d66887c742
尝试关注其他类似的堆栈溢出问题,但看起来这个包有很多依赖项。我找不到冲突。
我的build.gradle
依赖项:
dependencies
compile(project(":react-native-firestack"))
compile project(':react-native-onesignal')
compile project(':react-native-fbsdk')
compile project(':react-native-share')
compile project(':react-native-video')
compile project(':react-native-uuid-generator')
compile project(':react-native-udp')
compile project(':react-native-tcp')
compile project(':react-native-camera')
compile project(':react-native-contacts')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-image-picker')
compile(project(":react-native-google-signin"))
exclude group: "com.google.android.gms" // very important
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
【问题讨论】:
【参考方案1】:确保您在所有 google play 服务库中使用相同的版本: 例如:
compile "com.google.firebase:firebase-core:$project.ext.googlePlayServicesVersion"
compile "com.google.firebase:firebase-auth:$project.ext.googlePlayServicesVersion"
compile "com.google.firebase:firebase-database:$project.ext.googlePlayServicesVersion"
project.ext
googlePlayServicesVersion = '10.2.0'
【讨论】:
这是我在 build.gradle 文件中的内容:compile 'com.google.android.gms:play-services:9.8.0' compile 'com.google.firebase:firebase-messaging:9.0.0'
。我把它唱给compile 'com.google.android.gms:play-services:9.8.0' compile 'com.google.firebase:firebase-messaging:9.8.0'
。我仍然收到与更改之前相同的错误:Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback.class
。
索引切换到firebase,但google play服务版本仍需匹配: implementation 'com.google.android.gms:play-services-ads:10+' // GAID 匹配 implementation 'com. google.firebase:firebase-appindexing:10.+' // 应用索引【参考方案2】:
今天当我的依赖项如下时出现此错误:
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
但是当我将最后一个依赖项更改为以下内容时,它就消失了:
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
所以请确保您使用具有相同版本的依赖项。也就是说,支持库应该具有相同的版本,Firebase 和 Google Play 依赖项也是如此。
【讨论】:
【参考方案3】:我确定您的 build.gradle 文件中的某处有 apply plugin: 'com.google.gms.google-services'
,可能在顶部。
此行必须在依赖项块之后 - 这允许插件确定您使用的 Play 服务版本。
您可以参考https://firebase.google.com/docs/android/setup#add_the_sdk了解更多信息。
在您的情况下,它应该如下所示:
dependencies
compile(project(":react-native-firestack"))
compile project(':react-native-onesignal')
compile project(':react-native-fbsdk')
compile project(':react-native-share')
compile project(':react-native-video')
compile project(':react-native-uuid-generator')
compile project(':react-native-udp')
compile project(':react-native-tcp')
compile project(':react-native-camera')
compile project(':react-native-contacts')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-image-picker')
compile(project(":react-native-google-signin"))
exclude group: "com.google.android.gms" // very important
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
// after dependencies block
apply plugin: 'com.google.gms.google-services'
【讨论】:
【参考方案4】:我不确定这是否是最好的解决方法,但我可以通过进入 /node_modules/react-native-firestack/android/build.gradle 并将所有 10.0.1 替换为 10.2 来解决问题。 0,然后确保我在自己的 android/build.gradle 中到处使用 10.2.0。
【讨论】:
【参考方案5】:只需在您的 build.gradle 中添加以下内容
android
configurations
all*.exclude module: 'play-services-awareness'
【讨论】:
【参考方案6】:将此添加到您的 build.gradle 并运行 gradle findDuplicates
task findDuplicates
doLast
def findMe = 'com/google/android/gms/internal/zzble.class'
configurations.compile.asFileTree.matching
include '**/*.jar'
.files.each File jarFile ->
zipTree(jarFile).visit FileVisitDetails fvd ->
if (fvd.path == findMe)
println "Found $findMe in $jarFile.name"
【讨论】:
它给出了错误Error:(202, 1) Execution failed for task ':app:findDuplicates'. > Could not get unknown property 'runtime' for configuration container.
将代码从configurations.runtime.xxx
更改为configurations.compile.xxx
,它应该可以工作以上是关于尝试添加包时出现错误“重复条目:com/google/android/gms/internal/zzble.class”的主要内容,如果未能解决你的问题,请参考以下文章
尝试在 https://pub.dartlang.org 查找包 ABC 时出现 TLS 错误
尝试在我的 RoR 项目上“安装包”时出现错误。 [视窗 8]