问题
I'm using angular 4 and ionic 3. Now when i run "ionic cordova run android" It gives me the following error:
"more than one library with package name 'com.google.android.gms.license'"
My project.property file:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:27.1.0
cordova.system.library.2=com.android.support:support-v4:27.1.0
cordova.system.library.3=com.android.support:support-v4:27.1.0
cordova.system.library.4=com.android.support:appcompat-v7:25.+
cordova.gradle.include.1=cordova-plugin-firebase/starter-build.gradle
cordova.system.library.5=com.google.gms:google-services:+
cordova.system.library.6=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.7=com.google.firebase:firebase-core:+
cordova.system.library.8=com.google.firebase:firebase-messaging:+
cordova.system.library.9=com.google.firebase:firebase-crash:+
cordova.system.library.10=com.google.firebase:firebase-config:+
My dependencies in build.gradle file :
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v4:27.1.0"
compile "com.android.support:appcompat-v7:25.+"
compile "com.google.gms:google-services:+"
compile "com.google.android.gms:play-services-tagmanager:+"
compile "com.google.firebase:firebase-core:+"
compile "com.google.firebase:firebase-messaging:+"
compile "com.google.firebase:firebase-crash:+"
compile "com.google.firebase:firebase-config:+"
// SUB-PROJECT DEPENDENCIES END
}
Thanks in advance :)
回答1:
Change your project.property file to:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:27.1.0
cordova.system.library.2=com.android.support:support-v4:25.+
cordova.system.library.3=com.android.support:appcompat-v7:25.+
cordova.system.library.6=com.google.firebase:firebase-core:11.8.0
cordova.system.library.7=com.google.firebase:firebase-messaging:11.8.0
cordova.system.library.8=com.google.firebase:firebase-crash:11.8.0
cordova.system.library.9=com.google.firebase:firebase-config:11.8.0
cordova.system.library.9=com.google.firebase:firebase-auth:11.8.0
cordova.system.library.9=me.leolin:ShortcutBadger:1.1.4@aar
回答2:
Please update your build.gradle file
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
changes your version to 2.3.0
its worked for me... Thanks
回答3:
I think your issue comes here:
compile "com.google.gms:google-services:+"
compile "com.google.android.gms:play-services-tagmanager:+"
Rather than importing gms services like this, you should only import specific libraries.
回答4:
You are using together those both library.
compile "com.google.gms:google-services:+"
compile "com.google.android.gms:play-services-tagmanager:+"
this "com.google.gms:google-services:+"
library has all play service libraries.
Remove this dependency "com.google.android.gms:play-services-tagmanager:+"
and it will work.
But still This is not a good way to add com.google.gms:google-services:+
, because un-necessary you are adding all google's dependency.
Instead of this dependecy you can use specific dependency, for example if you are using map, then use only map play service.
Here is the list of all play service dependency https://developers.google.com/android/guides/setup .
I suggest you add only required dependency instead of play service universal dependency.
回答5:
- If you've already changed version at /android/build.gradle but not work yet. Maybe you need check some library package at node_modules.
- Eg: react-native-onesignal also compile some play-services with highest version (they use +) so it can make this issue.
- You can put a script at root directory and add {"scripts": {"postinstall": "node changeVersionGoogleService.js"}} in package .json so it can run to auto change your version when you npm install.
- This is the script: https://gist.github.com/duytq94/47ef945131b61de538447d449813b3d4
- My script at now auto change 'react-native-onesignal', 'react-native-admob', 'react-native-maps', 'react-native-google-sign-in'
回答6:
None of the solutions discussed here worked for me so I went on to
- renamed the
/platform/android
folder and Remove android platform - add android platform
ionic cordova platform add android
- faced another issue with facebook due to this which has a solution here where you need to add your app id and name in
platforms/android/app/src/main/res/values/strings.xml
file
compiled worked fine after that.
The problem occurred for me when upgrading to cordova 7.
回答7:
just Add :
googlePlayServicesVersion=11.8.0
to your gradle.properties
have fun ...
来源:https://stackoverflow.com/questions/49406185/more-than-one-library-with-package-name-com-google-android-gms-license