When using google+ cordova plugin https://github.com/EddyVerbruggen/cordova-plugin-googleplus along with admob plugin https://github.com/appfeel/admob-google-cordova
Encounter this error in Cordova CLI:
Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false
Looks like one of the plugin is using deprecated references to google play services.
While executing gradle build google play services is referenced to same app twice and gradle build fails.
As an alternative I tried skipping gradle build to use --ant build that doesn't work with a warning - plugin uses a system library and cannot build using ant.
Spending whole day I was able to resolve this error and my build was a success.
I created my cordova project, I first added both the plugins from git url using gitbash. Then I made 3 simple modifications before executing "Cordova platform add android" CLI command.
a) Go to <your-app>\plugins\cordova-admob\plugin.xml
replace "<dependency id="cordova-google-play-services" />
" with "<framework src="com.google.android.gms:play-services-ads:+" />
"
My research: <dependency id="cordova-google-play-services" />
is now deprecated and we need to use <framework>
tag.
b) Go to <your-app>\platforms\android\build.gradle
add this line to the end of file "configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
"
See below:
****************ADD AFTER THIS*********************
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}
****************ADD AFTER THIS*********************
configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
Gradle docs encourages you not to edit this file with a comment inline > // GENERATED FILE! DO NOT EDIT!
As a standard practice add this to build-extras.gradle, I was not that lucky it failed so I added to build.gradle