Подтвердить что ты не робот

Получение ошибки "дублирующаяся запись: 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'
}
4b9b3361

Ответ 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'
}

Ответ 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 и запустите 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"
                }
            }
        }
    }
}

Ответ 4

Я уверен, что у вас есть apply plugin: 'com.google.gms.google-services' где-то в файле build.gradle, вероятно, сверху.

Эта строка должна быть после блока зависимостей - это позволяет плагину определить, какую версию служб 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'

Ответ 5

Я не уверен, что это лучшее исправление, но я могу преодолеть проблему, перейдя в / node_modules/react-native-firestack/android/build.gradle и заменив все 10.0.1 на 10.2.0, а затем убедитесь, что я использую 10.2.0 во всем своем собственном файле android/build.gradle.

Ответ 6

Просто добавьте следующее в свой build.gradle

    android {
            configurations {
            all*.exclude module: 'play-services-awareness'
            }
    }