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

More than one library with package name 'com.google.android.gms.license' #857

Open
jurajkrivda opened this issue Mar 21, 2018 · 57 comments
Open

Comments

@jurajkrivda
Copy link

During the build I received this error message:

Execution failed for task ':react-native-fcm:processReleaseResources'.

Error: more than one library with package name 'com.google.android.gms.license'

@sy92th
Copy link

sy92th commented Mar 21, 2018

Add config in android/build.gradle

...
allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                // Add force (11.4.0 is version you want to use)
                force 'com.google.firebase:firebase-messaging:11.4.0'
                force 'com.google.firebase:firebase-core:11.4.0'
                force 'com.google.android.gms:play-services-gcm:11.4.0'
            }
        }
    }
}

@masteryoda2596
Copy link

Thank @sy92th . It Worked for Me

@chocnut
Copy link

chocnut commented Mar 21, 2018

@sy92th it worked for me too, but I use 11.8.0 so yeah

@tuanmai
Copy link

tuanmai commented Mar 21, 2018

@sy92th It worked for me too.
But could you help us to understand the reason? All of our devs encountered that issue this morning without changing anything in the configuration.
TIA

@sy92th
Copy link

sy92th commented Mar 21, 2018

Today, google released version 12.0.0 for library "com.google.firebase".
You can see in ../node_modules/react-native-fcm/android/build.gradle:

dependencies {
    ...
    compile 'com.google.firebase:firebase-core:+'
    compile 'com.google.firebase:firebase-messaging:+'
}

react-native-fcm will use last version of "com.google.firebase:firebase-core " and "com.google.firebase:firebase-messaging"
It's not compatible with the current version of "react-native-fcm" so I lowered the version and it worked

@yangtaufoo
Copy link
Contributor

yangtaufoo commented Mar 21, 2018

Hi guys, I've made a perm fix for this @ #859!

You can easily fix this (by defining your own google services version) by adding googlePlayServicesVersion=<your_version> in your gradle.properties, assuming you have my pull request.

Do let me know if there are any issues!

@isnifer
Copy link

isnifer commented Mar 21, 2018

@sy92th thanks!

@WidgetPMT
Copy link

@sy92th Thanks a lot!

@ikhsanalatsary
Copy link

@sy92th Thanks. save my day

@manojbhardwaj
Copy link

manojbhardwaj commented Mar 21, 2018

it works but after that my Android App crashes on starting #861

@kkarmalkar
Copy link

I am getting `Error:Execution failed for task ':react-native-camera:processReleaseResources'.

Error: more than one library with package name 'com.google.android.gms.license'` error while building Android app.

Please let me know solution to fix this.

@yangtaufoo
Copy link
Contributor

@kkarmalkar you will have to make the same changes for the gradle file in react-native-camera.

@kkarmalkar
Copy link

@yangtaufoo Can you please paste exact (sample) lines to add in gradle file

@yangtaufoo
Copy link
Contributor

@kkarmalkar react-native-camera/react-native-camera#1370 (comment) please refer to this for the fix

@petro-shkuratenyuk
Copy link

petro-shkuratenyuk commented Mar 21, 2018

I added this code in the end of android/build.gradle and I still have same error

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

did i miss anything?

Error:

Execution failed for task ':react-native-google-analytics-bridge:processReleaseResources'.
> Error: more than one library with package name 'com.google.android.gms.license'

@yangtaufoo
Copy link
Contributor

@petro-shkuratenyuk you need to paste a snippet of your error. However, i would assume that some other libraries do have google play dependencies too. They also need to fix their gradle files.

@yangtaufoo
Copy link
Contributor

guys, please refer to the fix: #859

@vinipachecov
Copy link

Just check where you are using the library and don't use the latest version. Check it out:

dependencies {
    
// DON'T
//    compile 'com.google.android.gms:play-services-auth:+'
// YES
    compile 'com.google.android.gms:play-services-auth:9.2.1' 
}

At least until it is fixed, I'll use like this.

@onedazy
Copy link

onedazy commented Mar 21, 2018

I think my problem comes from Onesignal. Anyone else who is using onesignal?

@yangtaufoo
Copy link
Contributor

the fix is analogous to any packages that have the issue. just make sure you do not have any google related dependencies defined with “+”

@evollu
Copy link
Owner

evollu commented Mar 21, 2018

@yangtaufoo I'm still a bit confused.
Is auto upgrading to v12 causing the issue?

@yangtaufoo
Copy link
Contributor

yangtaufoo commented Mar 21, 2018

@evollu You have to add the ext object with the property(s) you wish to override in your android/build.gradle (Reference: https://developer.android.com/studio/build/gradle-tips.html#configure-project-wide-properties)

@evollu
Copy link
Owner

evollu commented Mar 21, 2018

@yangtaufoo I mean what is the root cause of
Error: more than one library with package name 'com.google.android.gms.license'

@yangtaufoo
Copy link
Contributor

yangtaufoo commented Mar 21, 2018

@evollu Google updated their Google API for Android (https://developers.google.com/android/guides/releases) and it caused multiple libraries to fail, still trying to find what’s the root cause. Will get back once I’ve got an answer but using an old version is the best fix for now as the wildcard “+” will choose the latest at 12.0.0.

Edit: I have a gut feeling it’s related to this. (https://stackoverflow.com/questions/48365687/gradle-exclude-group-from-compile). Might want to look into it by using it in the test example

@nhancv
Copy link

nhancv commented Mar 22, 2018

My approach is scan all android project and update version of google play services directly to each module build.gradle
Detail here: https://medium.com/p/2fd245027832
Hope it can help you.

@akvsh-r
Copy link

akvsh-r commented Mar 22, 2018

@mcconkiee You can override it see this

@tobob
Copy link

tobob commented Mar 22, 2018

Non of above works for me :(

After all this resolve issue

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'
                }
            }
        }
  }
}

android/build.grandle

@Hipe2017
Copy link

work Perfect for me Thanks a lo.

@evollu evollu closed this as completed Mar 22, 2018
@evollu evollu reopened this Mar 22, 2018
@jokleber85
Copy link

sorted out... thanks

@evollu
Copy link
Owner

evollu commented Mar 22, 2018

@yangtaufoo can you point me some document regarding what I need to do for playservice v12?

@onedazy
Copy link

onedazy commented Mar 22, 2018

if all above doesn' t work try this
Try to find all your packages with gms included in your node modules.
Do this to your android/build.gradle

allprojects {
    repositories {

        // Temp fix for com.google.android.gms.license
        configurations.all {
            resolutionStrategy {

                // Put your gms packages here with 11.8.0 attached
                force "com.google.android.gms:play-services-analytics:11.8.0"
                force "com.google.android.gms:play-services-auth:11.8.0"
                force "com.google.android.gms:play-services-gcm:11.8.0"
                force "com.google.android.gms:play-services-location:11.8.0"
            }
        }

        mavenLocal()
        jcenter()
        
        maven { url "https://maven.google.com" }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

@jokleber85
Copy link

platform/android/build.gradle

@huoguoislife
Copy link

Hi I have one question about editing the files.
Can we directly edit the build.gradle file or do we need any other tools to do it?
Thank you !

@Hipe2017
Copy link

Hipe2017 commented Mar 23, 2018 via email

@huoguoislife
Copy link

Thank you !! I will try it now :))

@Hipe2017
Copy link

Hipe2017 commented Mar 23, 2018 via email

@ujwal-setlur
Copy link

This works for me in android/build.gradle:

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://jitpack.io" }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {                                  // <-- Add this
            url 'https://maven.google.com/' 
            name 'Google'
        }
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                def googlePlayServicesVersion = '11.8.0'
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion googlePlayServicesVersion
                }
                if (requested.group == 'com.google.firebase') {
                    details.useVersion googlePlayServicesVersion
                }
            }
        }
    }
}

@yangtaufoo
Copy link
Contributor

@evollu It will take some time as I'm not very familiar with the Google API framework and your library

@yangtaufoo
Copy link
Contributor

@html5ravi
Copy link

@tobob thank you boss, its working like charm!

@huoguoislife
Copy link

I was working on Ionic pro package and still can not solve this problem after trying all the solutions above. Somehow using the command $cordova build android it succeed and generate the apk file I need. Not sure where or what the problem is.
Thank you all anyway!!

@tobob
Copy link

tobob commented Mar 23, 2018

however I now don't use my resolution, I did update package to latest version and it works well

@yanniser
Copy link

@sy92th It worked for me too. I just had to add
force 'com.google.firebase:firebase-analytics:11.8.0'

to discover that I just printed the gradle dependency graph
./gradlew app:dependencies --configuration compile

and looked the 12.0.0 occurences

@cubissimo
Copy link

cubissimo commented Mar 23, 2018

but if i want to use the 12.0.0 version?

As we know fire functions is avaiable since 12.

is there a way to solve that without downgrading?

@cubissimo
Copy link

Updating gradle to 4.1 seems to solve all conflicts..

@ujwal-setlur
Copy link

@cubissimo Indeed, I ubgraded to gradle 4.6, and using Google Play Services 12.0.0 built just fine. Thanks!

@Salakar
Copy link

Salakar commented Apr 5, 2018

All,

Whilst forcing the versions to be lower than v12 works (as above) this isn't a long term solution and you'll eventually be unable to use some libraries that do keep up to date with GMS versions such as ourselves (react-native-firebase).

The recommended approach would be to update your android project to use the latest gradle wrapper and android build tools, here's some instructions taken from our React Native Firebase v4 change log to help you do this:

Upgrading gradle and Android build tools


Due to some breaking changes in v12 of the Android libs, you'll need to upgrade your Gradle version to at least v4.4 and make a few other tweaks as follows:

  1. In android/gradle/wrapper/gradle-wrapper.properties, update the gradle URL to gradle-4.4-all.zip
  2. In android/build.gradle check that you have google() specified in the buildScript repositories section:
buildscript {
    repositories {
        jcenter()
        google()  // <-- Check this line exists
        ...
    }
  1. In android/build.gradle update Android build tools to version 3.1.0:
classpath 'com.android.tools.build:gradle:3.1.0'
  1. In android/app/build.gradle update all your compile statements to be implementation, e.g.
implementation(project(':react-native-firebase')) {
    transitive = false
}
  1. In android/app/build.gradle, update all the firebase and gms dependencies to 12.0.1

Patching outdated RN modules

In an ideal world RN modules are all kept up to date on gradle dependencies and such; but in the real world most might never upgrade their GMS versions/gradle build files, this isn't the end of the line though. You can successfully patch any of the modules you want to change the versions / dependency definitions of (e.g. to use the new gradle api/implementation/compileOnly syntax) using the patch-package npm module.

It's pretty straight-forward:

  1. Change/correct the modules you have issues with inside your node_modules dir and get them all building successfully together
  2. Once your android project builds and runs smoothly then run patch-package modulename-1 modulename-2 etc in the root of your project and it will create a patches directory in your project (contains all the changes you made in node_modules for each of the packages you specified in the command)
  3. Commit this new directory as part of your git repo
  4. Add patch-package as a post-install script on your package.json and it will auto patch after every npm/yarn install
  5. Profit 🎉

Links for reference:
https://github.com/invertase/react-native-firebase/blob/master/android/build.gradle#L83
https://github.com/invertase/react-native-firebase/blob/master/tests/android/app/build.gradle#L75

@murilo3m
Copy link

murilo3m commented May 9, 2018

@tobob thanks, this worked for me, additionaly I changed this in my package.json "PLAY_SERVICES_VERSION": "11.8.0",

@Gops1994
Copy link

Gops1994 commented Oct 8, 2018

Everything is fine but when i install app on my device, it crash after install

screenshot_2018-10-08-12-04-53-508_com miui bugreport_20181008_120541885

@Gops1994
Copy link

Gops1994 commented Oct 8, 2018

below is my manifest file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:launchMode="singleTop"
    >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

  <receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
  <receiver android:enabled="true" android:exported="true"  android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
     <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED"/>
          <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
          <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
  </receiver>
</application>

@Gops1994
Copy link

Gops1994 commented Oct 8, 2018

below is my gradle configuration

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.mysalesplus"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
dependencies {
compile project(':react-native-device-info')
compile project(':react-native-vector-icons')
compile project(':react-native-fcm')
compile project(':react-native-touch-id')
compile project(':react-native-keychain')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.facebook.react:react-native:+'
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'com.google.android.gms:play-services-gcm:12.0.1'

// From node_modules

}
apply plugin: "com.google.gms.google-services"

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

No branches or pull requests