Ionic build android issue with gradle

Hey guys,

Has anyone experienced this problem while doing an ionic build android:

:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:processDebugResources’. > Error: more than one library with package name ‘com.google.android.gms’ You can temporarily disable this error with android.enforceUniquePackageName=false However, this is temporary and will be enforced in 1.0

My ionic build android use to work fine (but i think it wasnt using gradle). I have a few cordova plugins installed but not sure if this could be a cause. And the dependencies in the auto generated build.gradle look like this:

dependencies {
compile fileTree(dir: ‘libs’, include: ‘*.jar’)
// SUB-PROJECT DEPENDENCIES START
debugCompile project(path: “:CordovaLib”, configuration: “debug”)
releaseCompile project(path: “:CordovaLib”, configuration: “release”)
debugCompile project(path: “:com.google.playservices:surf-google-play-services_lib”, configuration: “debug”)
releaseCompile project(path: “:com.google.playservices:surf-google-play-services_lib”, configuration: “release”)
compile “com.google.android.gms:play-services-ads:+”
// SUB-PROJECT DEPENDENCIES END
}

I would be grateful for any help.

Cheers,
Wes

Ive narrowed it down slightly. If I remove the admobpro cordova plugin I no longer get this problem. But I still dont understand why this cordova plugin is causing this issue.

Any thoughts?

My guess is you have two plugins that both bring in google-play-services as their dependency, but under a different name so you end up with a duplicate.

2 Likes

Hey thanks for the help. It was indeed another plugin. I had a google play services cordova plugin installed. I assumed it was a dependency of the admobpro plugin but it wasnt. So when removed it worked fine. Thanks very much.

For future reference, if you have Gradle dependency errors, you can resolve them by extending your Gradle build file:

I think this is a scenario where you could have done this.

Regards,

Any way you could go into detail about how one would use this to exclude one of the two duplicate libraries? I have no experience whatsoever with gradle and am a bit stumped about where to start looking. In my case the two plugins are:

onesignal-cordova-plugin and cordova-plugin-analytics which includes cordova-google-play-services

thanks!

I’m my case the plugin nl.x-services.plugins.googleplus changed the name to cordova-plugin-googleplus, that’s why the duplications of packages.

I ran the command: cordova plugin rm nl.x-services.plugins.googleplus since cordova-plugin-googleplus is the new package with the correct name. Now it works. :smile:

You need to use:
ionic platform add android@5.0.0

if u already added android platform, you should to remove that before
and you can add using
ionic platform add android@5.0.0