When I try to run the command ionic cordova build android out error as title above. Then I try to remove one of the gms, when I build again the deleted it appears again. how to solve this?.
Here is my dependencies of my build.gradle :
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.google.android.gms:play-services-auth:+" // i remove this
compile "com.google.android.gms:play-services-identity:+"
compile "com.facebook.android:facebook-android-sdk:4.+"
// SUB-PROJECT DEPENDENCIES END
}
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 different versions for the com.google.android.gms, as such:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.google.android.gms:play-services-auth:+
cordova.system.library.3=com.google.android.gms:play-services-identity:+
cordova.system.library.4=com.google.android.gms:play-services-location:11.+
This makes the library.2 and library.3 require one version while the library.4 requires a more specific version, thus causing the duplicate library reference during compiling.
While I don't think this should be the final solution, adding the specific library worked for me. As such:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.google.android.gms:play-services-auth:11.+
cordova.system.library.3=com.google.android.gms:play-services-identity:11.+
cordova.system.library.4=com.google.android.gms:play-services-location:11.+
in build.gradle add this
configurations.all {
resolutionStrategy {
force "com.google.android.gms:play-services-ads:11.8.0"
force "com.google.android.gms:play-services-base:11.8.0"
force "com.google.android.gms:play-services-gcm:11.8.0"
force "com.google.android.gms:play-services-analytics:11.8.0"
force "com.google.android.gms:play-services-location:11.8.0"
force "com.google.android.gms:play-services-basement:11.8.0"
force "com.google.android.gms:play-services-tagmanager:11.8.0"
force 'com.google.firebase:firebase-core:11.8.0'
force 'com.google.firebase:firebase-crash:11.8.0'
force 'com.google.firebase:firebase-auth:11.8.0'
force 'com.google.firebase:firebase-common:11.8.0'
force 'com.google.firebase:firebase-config:11.8.0'
force 'com.google.firebase:firebase-messaging:11.8.0'
}
}
if that doesn't work, search in your project the string '12.0.0' and add in the list above the missing library
This happening because of Play services 12.0.0. I went ahead and downgraded the dependencies to 11.8.0 ( last known working version for my project). I'm using react native. I had 2 dependencies which were pulling in 12.0.0 of google play services - com.google.android:play-services...12.0.0 Hope this helps.
Things i had to do to get the build to succeed on my Ionic3 App:
- Add Plugin cordova-android-play-services-gradle-release
- Remove and re-add the android platform
- 11.+ in platform/android/project.properties file for libraries ( Especially if you're using firebase )
- 11.+ for dependencies in platforms/android/cordova-plugin-firebase/-build.gradle
- The above changes in platforms/android/build.gradle
This might be the worst possible way to get things work, but kinda saved my life. Hope this helps someone!
Maybe it related to new release of Google Play services 12.0.0(released at March 20, 2018)
I've resolved it fixing dependencies:
Add config in android/build.gradle
allprojects {
repositories {
...
configurations.all {
resolutionStrategy {
// Add force (11.0.0 is version you want to use)
force 'com.google.firebase:firebase-core:11.0.0'
force 'com.google.firebase:firebase-crash:11.0.0'
force 'com.google.firebase:firebase-analytics:11.0.0'
force 'com.google.firebase:firebase-messaging:11.0.0'
force 'com.google.android.gms:play-services-base:11.0.0'
force 'com.google.android.gms:play-services-maps:11.0.0'
force 'com.google.android.gms:play-services-wallet:11.0.0'
}
}
}
}
Set of dependencies are from your android/app/build.gradle
In my case
npm update
cordova platform remove android
cordova platform add android@6.4.0
And replace in platform/android/projet.properties
cordova.system.library.1=com.android.support:support-v4+
To
cordova.system.library.1=com.android.support:support-v4:26+
For reference, from: https://developers.google.com/android/guides/releases
Google APIs for Android
March 20, 2018 - Version 12.0.0
Known Issues with version 12.0.0
- ...
- -license POM dependencies cause "more than one library with package name ‘com.google.android.gms.license'" issues in Ionic Pro.
- ...
We will provide an updated 12.0.1 release to address these issues soon.
My Workaround
(based on jeremy castelli's answer and keldar's subsequent comment)
I am using the following workaround (and I stress, this is a workaround).
Add the following to the bottom of build-extras.gradle, creating the file if necessary.
configurations.all {
resolutionStrategy {
force 'com.google.firebase:firebase-core:11.8+',
'com.google.firebase:firebase-messaging:11.8+',
'com.google.firebase:firebase-crash:11.8+',
'com.google.firebase:firebase-config:11.8+',
'com.google.firebase:firebase-auth:11.8+',
'com.google.android.gms:play-services-tagmanager:11.8+',
'com.google.android.gms:play-services-location:11.8+'
}
}
It is important to include all firebase and all android.gms library references, if you miss just one from here, it will still fail to build. Grep your gradle files for all the references. In my case I had missed firebase-auth which was referenced in the firebase plugin folder's .gradle file.
What resolutionStrategy force does is override the version choices made by the project/plugins and force gradle to reference a specific version.
There is no need to edit project.properties or any other gradle files using this workaround.
When you run the command ionic cordova you can change the version,I have the same error, and i fixed the problem by changing version my nodes modules, my plugin cordova, version off android studio.
My conf below:
ANDROID STUDIO: 3.0.0
pply plugin: 'com.android.application'
buildscript { repositories { jcenter() maven { url "https://maven.google.com" } }
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.1.1' // google-services plugin
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle. allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } }
task wrapper(type: Wrapper) { gradleVersion = '2.14.1' }
...
...
...
...
...
apply plugin: 'com.google.gms.google-services'
Gradle version : 3.3 com.google.android.gms:play-services:11.4.2
Some times node module and cordova plugin gets himself wrong, so you do delete manually in the folder. Don’t forget to remove and add cordova plugin when you update it.
Try to go in android studio => files => project structure => project =>ok Normally android studio should synchonize your gradle
OR
Error: more than one library with package name com.google.android.gms.license
In my case, the problem was because I was including:
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.gms:play-services:4.4.52'
both the wearable play services, and the regular. I commented out the wearable part, and it works. Not sure if I'll need it, but it was included by default by the project wizard
I hope I can help you. Keep going !
just change platform/android/project.properties to
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.google.android.gms:play-services-auth:11.+
cordova.system.library.3=com.google.android.gms:play-services-identity:11.+
cordova.system.library.4=com.google.android.gms:play-services-location:11.+
this worked for me
It works for me.
node_modules/react-native-camera/android/build.gradle:
dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.google.android.gms:play-services-gcm:11.8.0' // update by me on
20180321
}
UPDATE
The cause of this error has been identified as a bug in v12.0.0 of the Google Play Services library:
Known Issues with version 12.0.0 -license POM dependencies cause "more than one library with package name ‘com.google.android.gms.license'" issues in Ionic Pro.
The bug has been fixed in v12.0.1 of the Google Play Services library:
Restores unique package names for runtime linked -license artifacts which affected some build systems' (e.g. Ionic Pro) compatibility issues.
Therefore specifying v12.0.1 or above of the Play Services Library via the cordova-android-play-services-gradle-release plugin resolves the issue, for example:
cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=12.+
For me, it was a matter of adding version number to Google Play Services in project.properies file.
So you need to change something like:
android.library.reference.1=CordovaLib
cordova.system.library.2=com.google.android.gms:play-services-auth:
cordova.system.library.3=com.google.android.gms:play-services-identity:
to:
android.library.reference.1=CordovaLib
cordova.system.library.2=com.google.android.gms:play-services-auth:11.
cordova.system.library.3=com.google.android.gms:play-services-identity:11.
Only this worked for me in build.gradle:
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'
}
}
}
}
}
https://github.com/evollu/react-native-fcm/issues/857#issuecomment-375243825
1. Go to project.properties (in your platform folder)
2. I was using just google analytics in my "project.properties" and had to add " 11.+" to the end of the version and that worked for me. Not sure if that's long term fix but it did the trick.
cordova.system.library.2=com.google.android.gms:play-services-analytics:11.+
I was facing the same error in my ionic project, after little search I have read about to upgrade the Android platform which is required for latest Android Gradle Plugin in order to build the app.
The solution to is very easy just follow the below mentioned step.
- Remove your existing Anroid platform
ionic cordova platform remove android
Add minimum version Android SDK Build Tools 26.0.2 through Android SDK Manager to use latest Android Gradle Plugin in order to build the app
Add minimum version for Android platform
ionic cordova platform add android@^6.4.0
来源:https://stackoverflow.com/questions/49398026/error-more-than-one-library-with-package-name-com-google-android-gms-license