question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility with react-native-firebase `Error: more than one library with package name 'com.google.android.gms.license'`

See original GitHub issue

Hello,

I’m trying to use this library along with react-native-firebase in my project. But when I try to compile, I’m getting the following error:

:react-native-push-notification:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-push-notification:processReleaseResources'.
> Error: more than one library with package name 'com.google.android.gms.license'

I believe your Android dependency compile 'com.google.android.gms:play-services-gcm:+' needs to support Gradle versioning, kinda like: https://github.com/rebeccahughes/react-native-device-info/blob/e2c877f461c4181113abb3ff8f6bb8dfe89de0fb/android/build.gradle#L30 so the clients have the option of explicitly setting a version for that dependency.

Other packages seem to be affected as well by this change: https://github.com/rebeccahughes/react-native-device-info/issues/365

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:16

github_iconTop GitHub Comments

9reactions
opp100commented, Mar 21, 2018

Hey mate,

I got same library as yours. I tried your suggestion. Now I could successfully build for Android.

I changed the build.gradle file in ./node_modules/react-native-push-notification/

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.library'

def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "+"

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.facebook.react:react-native:+'
    compile "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion" // double quote for merge field
    compile 'me.leolin:ShortcutBadger:1.1.8@aar'
}

And in the main project build.gradle file in ./android/app/

dependencies {
    ...

    def googlePlayServicesVersion = project.googlePlayServicesVersion

    compile(project(':react-native-maps')){
      exclude group: 'com.google.android.gms'
    }
    compile 'com.google.android.gms:play-services-base:11.8.0'
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile ('com.google.android.gms:play-services-gcm:11.8.0') {
        force = true;
    }
    compile(project(':react-native-device-info')) {
        exclude group: 'com.google.android.gms'
    }
    compile(project(':react-native-push-notification')) {
        exclude group: 'com.google.android.gms'
    }

  ...

}

Also I added the version in gradle.properties file in ./android/

googlePlayServicesVersion=11.8.0
6reactions
MyGuySicommented, Mar 22, 2018

It’s worth adding that switching to a forked version is not necessary to fix this issue (temporarily). I simply added the following to android/build.gradle

allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
              force "com.google.android.gms:play-services-gcm:11.8.0"
            }
        }
    }
}

That covers me because I’m only using react-native-push-notification so I only need GCM. If you use other things like maps or firebase you’ll need to add those as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

than one library with package name 'com.google.android.gms ...
Execution failed for task ':react-native-device-info:processReleaseResources'. Error: more than one library with package name 'com.google.
Read more >
than one library with package name com.google.android.gms ...
I've faced this issue quite recently and the problem for me was that for some reason the android project.properties file was generated with ......
Read more >
Firebase: Android build error with Error: more than one library ...
I am trying to build android apk, but the build command failed with error,. 'Error: more than one library with package name 'com.google.android....
Read more >
Frequently Asked Questions - React Native Firebase
A common build time error when using libraries that require google play services is of the form: 'Failed on android with com.android.dex.DexException: Multiple...
Read more >
Integrate Google Login in React Native (Android) apps with ...
Learn how to setup Google Login in React Native apps using Firebase. Connect Firebase to authenticate and test on android.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found