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

前端 未结 6 1085
囚心锁ツ
囚心锁ツ 2020-12-16 13:31

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
:         


        
相关标签:
6条回答
  • 2020-12-16 13:49

    I'm not sure if this is the best fix, but I can get past the problem by going into /node_modules/react-native-firestack/android/build.gradle and replacing all of the 10.0.1 with 10.2.0, and then making sure I use 10.2.0 everywhere in my own android/build.gradle.

    0 讨论(0)
  • 2020-12-16 13:49

    Just add following in your build.gradle

        android {
                configurations {
                all*.exclude module: 'play-services-awareness'
                }
        }
    
    0 讨论(0)
  • 2020-12-16 13:50

    I got this error today when my dependencies were the following:

    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'
    

    But it went away when I changed the last dependency to the following:

    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'
    

    So make sure you use dependencies with same versions. That is the support libraries should have same version, and same goes for Firebase and Google Play dependencies.

    0 讨论(0)
  • 2020-12-16 13:51

    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'
    }
    
    0 讨论(0)
  • 2020-12-16 13:52

    Add this to your build.gradle and run 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"
                    }
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-16 13:53

    I'm sure you have apply plugin: 'com.google.gms.google-services' somewhere in your build.gradle file, probably on top.

    This line has to be after dependencies block - this allows the plugin to determine what version of Play services you are using.

    You can refer to https://firebase.google.com/docs/android/setup#add_the_sdk for more information.

    In your case it should look like this:

    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'
    
    0 讨论(0)
提交回复
热议问题