Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aligfl opened this issue Mar 21, 2018 · 16 comments

Comments

@aligfl
Copy link

aligfl commented Mar 21, 2018

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:
react-native-device-info/react-native-device-info#365

@opp100
Copy link

opp100 commented 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

@Compulsor-zz
Copy link

@zo0r could we get this as a fix? Is working like a charm!

@Compulsor-zz
Copy link

Currently forked the project with changes above. Until @zo0r hasn't implemented this, feel free to use THIS.

@aligfl
Copy link
Author

aligfl commented Mar 21, 2018

NICE! @compulsor I shall wait for a day or two before switching ;-)

@Compulsor-zz
Copy link

@aligfl yea I can't really wait, i've got a client that is expecting a PoC within a few days. Anyhow, glad I could help out!

@antsmo
Copy link

antsmo commented Mar 21, 2018

I love how this has caused to many projects to fail the build process... hope this change gets merged quickly

@tonyhb
Copy link

tonyhb commented Mar 21, 2018

Yep I'm also getting this very recently. Thanks for the heads up @opp100.

@aligfl
Copy link
Author

aligfl commented Mar 21, 2018

@compulsor how can I pull down your forked repo using npm?

@Compulsor-zz
Copy link

@aligfl npm install --save Compulsor/react-native-push-notification

@aligfl
Copy link
Author

aligfl commented Mar 21, 2018

Thanks @compulsor! much appreciated.

@stantoncbradley
Copy link

this fix worked for us, thanks so much! @zo0r would be great to merge this in so we can switch off the forked version

@Compulsor-zz
Copy link

@aligfl @stantoncbradley any time lads!

@antsmo
Copy link

antsmo commented 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

@Compulsor-zz
Copy link

Compulsor-zz commented Mar 22, 2018

@MyGuySi That ain’t needed at all. Just declare googlePlayServicesVersion=YOUR_WANTED_VERSION in your gradle.properties and my forked repo should talke care of the rest.

@antsmo
Copy link

antsmo commented Mar 22, 2018

@compulsor Sure but that means people having to switch their package over to your forked version, wait for this one to be updated and then switch back. Repeat that for every dependency you have that uses Google Play Services and then it just becomes much simpler to implement my alternative until all of your dependencies have been updated.

@haotangio
Copy link

Can somebody merge the fix and release a new version soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants