React-native-firebase: More than one library with package name 'com.google.android.gms.license'

Created on 22 Mar 2018  路  12Comments  路  Source: invertase/react-native-firebase

Issue

So a couple days ago I started to get this build error: More than one library with package name 'com.google.android.gms.license' while trying to build.

After googling, it seemed to be caused by a new release of google play services, to projects pointing their dependencies to latest (i.e. like 'com.google.android.gms:play-services-auth:+', instead of an explicit version)

I couldn't find any "point to latest" style declarations in the relevant section of my app/build.gradle, though:

dependencies {
    compile(project(":react-native-google-signin")){
        exclude group: "com.google.android.gms"
    }

    compile 'com.google.android.gms:play-services-auth:11.2.0'

    // RNFirebase required dependencies
    compile(project(':react-native-firebase')) {
        transitive = false
    }
    compile "com.google.firebase:firebase-core:11.2.0"
    compile "com.google.android.gms:play-services-base:11.2.0"
    compile "com.google.firebase:firebase-analytics:11.2.0"
    compile "com.google.firebase:firebase-auth:11.2.0"
    compile "com.google.firebase:firebase-messaging:11.2.0"

    compile(project(':react-native-fbsdk')){
        exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
    }
    compile "com.facebook.android:facebook-android-sdk:4.22.1"
}

I still went ahead and tried this solution of putting the following on the android/build.gradle:

allprojects {
    repositories {
        configurations.all {
            resolutionStrategy {
                force "com.google.android.gms:play-services-gcm:11.2.0"
                force 'com.google.firebase:firebase-messaging:11.2.0'
                force 'com.google.firebase:firebase-core:11.2.0'
                force 'com.google.android.gms:play-services-auth:11.2.0'
            }
        }
        ....
    }
}

Now I don't get the licese error, but I get the following one:

./node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java:56: error: cannot access aet
    mAuth = FirebaseAuth.getInstance();
                        ^
  class file for com.google.android.gms.internal.aet not found
Note: ./node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java uses or overrides a deprecated API.

Environment

  1. Application Target Platform:

Android and iOS

  1. Development Operating System:

Ubuntu

  1. Build Tools:
  1. React Native version:

0.47.0

  1. RNFirebase Version:

2.2.1

Most helpful comment

I was getting the same thing, fixed it with this:

allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '11.8.0'
                }
                if (requested.group == 'com.google.firebase') {
                    details.useVersion '11.8.0'
                }
            }
        }
  }
}

From: https://github.com/evollu/react-native-fcm/issues/857#issuecomment-375243825

All 12 comments

Not really sure what to advise here. It's more than likely due to a mismatch of different versions somewhere along the line. Looks like you're using google-signin as well, so there might be a clash.

You might want to add all the firebase / google imports that you're using to the resolution strategy section?

I was getting the same thing, fixed it with this:

allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '11.8.0'
                }
                if (requested.group == 'com.google.firebase') {
                    details.useVersion '11.8.0'
                }
            }
        }
  }
}

From: https://github.com/evollu/react-native-fcm/issues/857#issuecomment-375243825

@escobar5 fix did not work for me, after it i'm getting error:

<my project dir>\node_modules\react-native-firebase\android\src\main\java\io\invertase\firebase\admob\RNFirebaseAdMobRewardedVideo.java:95: error: method does not override or implement a method from a supertype
  @Override                                                        
  ^
Note: C:\work\gwma-front-end\node_modules\react-native-firebase\android\src\main\java\io\invertase\firebase\notifications\RNFirebaseNotificationManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.               
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:react-native-firebase:compileReleaseJavaWithJavac FAILED

currently i'm only able to get react-native-firebase to work with 4.0.0-alpha.1 which is using 11.8.0

I'm having the exact same issue as @Grauzunas

Looks like the new play services v12 doing this: https://stackoverflow.com/questions/49406185/more-than-one-library-with-package-name-com-google-android-gms-license AND https://github.com/facebook/react-native/issues/18479

馃檲 am debugging this with someone right now - will post back if we come up with a work around

For v4 users - temporary resolution on this is to:

Add the following inside android/build.gradle:

subprojects {
    ext {
        playServicesVersion = '11.8.0'
    }

    project.configurations.all {
        resolutionStrategy {
            eachDependency { details ->
                // Force dependencies to use the same version.
                def versionSelector = details.requested
                if (versionSelector.group == 'com.google.firebase'
                        || versionSelector.group == 'com.google.android.gms') {
                    details.useVersion playServicesVersion
                }
            }
        }
    }
}

You'll then need to remove admob from the RNFirebase android package (otherwise the whole lib will not compile) - it requires v12+ due to deprecations. You can do so via an npm post install script, something like rm -rf node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/admob

We'll keep looking into it.

Upgrading gradle to 4+ seems to solve the problem to me

@cubissimo that would explain why I was unable to reproduce here, I'm on grade 4+ also

I have a Android project running on v4+ over here: https://github.com/invertase/react-native-firebase/tree/bridge-detox/tests-new for reference for those who want to upgrade. Just don't copy the RNFirebase android import (settings.gradle) directly - it's relative to the project and not coming from node modules - keep it the same as you do now.

@Salakar @cubissimo What's the proper way to update gradle? Sorry the lazyness, but a rushy week and I'm scared as hell of breaking the project :/

This is addressed in the latest release candidate for v4.

Check out the release notes for instructions on how to upgrade gradle: https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0-rc.3

Was this page helpful?
0 / 5 - 0 ratings