Error: more than one library with package name 'com.google.android.gms' using cordova plugin admob along with google plus for android

与世无争的帅哥 提交于 2019-12-17 20:59:41

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/34775891/error-more-than-one-library-with-package-name-com-google-android-gms-using-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!