错误:多个包名称为"com.google.android.gms"的库使用Cordova插件admob以及适用于Android的google plus [英] Error: more than one library with package name 'com.google.android.gms' using cordova plugin admob along with google plus for android

查看:140
本文介绍了错误:多个包名称为"com.google.android.gms"的库使用Cordova插件admob以及适用于Android的google plus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用google + cordova插件时 https://github.com/EddyVerbruggen/cordova-plugin-googleplus 以及admob插件 https://github.com/appfeel/admob-google-cordova

When using google+ cordova plugin https://github.com/EddyVerbruggen/cordova-plugin-googleplus along with admob plugin https://github.com/appfeel/admob-google-cordova

在Cordova CLI中遇到此错误:

错误:多个库的软件包名称为"com.google.android.gms" 您可以使用android.enforceUniquePackageName = false

Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false

插件之一似乎正在使用对Google Play服务的不推荐使用的引用.

Looks like one of the plugin is using deprecated references to google play services.

在执行gradle构建时,两次将同一个应用引用了Google Play服务,并且gradle构建失败.

While executing gradle build google play services is referenced to same app twice and gradle build fails.

作为一种替代方法,我尝试跳过gradle构建以使用--ant构建,该构建不适用于警告-插件使用系统库,而无法使用ant构建.

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.

我创建了cordova项目,首先使用gitbash从git url添加了两个插件.然后,在执行"Cordova platform add android" CLI命令之前,我做了3个简单的修改.

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)转到<your-app>\plugins\cordova-admob\plugin.xml将"<dependency id="cordova-google-play-services" />"替换为"<framework src="com.google.android.gms:play-services-ads:+" />"

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:+" />"

我的研究:<dependency id="cordova-google-play-services" />现在已被弃用,我们需要使用<framework>标签.

My research: <dependency id="cordova-google-play-services" /> is now deprecated and we need to use <framework> tag.

b)转到<your-app>\platforms\android\build.gradle将此行添加到文件"configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }"的末尾

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' }"

请参见下文:

****************此后添加*********************

****************ADD AFTER THIS*********************

if (hasProperty('postBuildExtras')) {
    postBuildExtras()
}

****************此后添加*********************

****************ADD AFTER THIS*********************

configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }

Gradle docs鼓励您不要使用内嵌评论>//GENERATED FILE编辑此文件!不要编辑!

Gradle docs encourages you not to edit this file with a comment inline > // GENERATED FILE! DO NOT EDIT!

作为一种常规做法,将其添加到build-extras.gradle中,我并不是很幸运失败了,所以我添加了build.gradle

As a standard practice add this to build-extras.gradle, I was not that lucky it failed so I added to build.gradle

这篇关于错误:多个包名称为"com.google.android.gms"的库使用Cordova插件admob以及适用于Android的google plus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆