尝试添加包时获取错误"duplicate entry: com/google/android/gms/internal/zzble.class"



我正在尝试将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'
}

确保您在所有Google Play Services Libs中使用相同版本:例如:

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

我今天在依赖项时遇到了这个错误:

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依赖项也是如此。

我确定您的build.gradle文件中的某个地方有apply plugin: 'com.google.gms.google-services',可能在上面。

此行必须是在依赖关系块之后的 - 这允许插件确定您正在使用的播放服务的版本。

您可以参考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'

我不确定这是否是最好的解决方案,但是我可以通过进入/node_modules/reaect-native-firestack/android/android/build.gradle来解决问题在10.2.0的10.0.1中,然后确保我在自己的android/build.gradle中使用10.2.0。

只需在您的build.gradle

中添加以下内容
    android {
            configurations {
            all*.exclude module: 'play-services-awareness'
            }
    }

将其添加到您的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"
                }
            }
        }
    }
}

相关内容

  • 没有找到相关文章

最新更新