Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

gradle - Getting the error "duplicate entry: com/google/android/gms/internal/zzble.class" when trying to add a package

I'm trying to add the react-native-firestack package to my app. But it keeps giving the following error :

: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.

I tried to add some packages to exclude group in several packages. But none worked. Here's the ./gradlew clean :app:dependencies result: https://gist.github.com/THPubs/8fe8b4b9c80e3c6cd49541d66887c742

Tried to follow other similar stack overflow question but looks like this package has a lot of dependencies. I was unable to find the conflict.

My build.gradle dependencies:

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'
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Make sure you use the same version in all your google play services libs: For example :

     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'
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...