多个库名称为“com.google.android.gms”(仅为8.1)和Cordova [英] More than one library with package name 'com.google.android.gms' (only 8.1) and Cordova
问题描述
当我更新Cordova和Android SDK(所有都在最后的版本)时,我的Cordova项目中出现了非常奇怪的错误。
自从更新我得到以下错误与gradle:错误:多个库包名为com.google.android.gms
Cordova插件没有更改,这在更新之前运行良好。
删除/添加Android平台或清除它并不能解决此错误。
这似乎是由于版本8.1的com.google.android.gms
我使用cordova-plugin-google-analytics使用:
com.google.android.gms:play-services-analytics:+ +表示最后的版本?)
由于这一行和更新项目不再构建
用一个值(7.5.0等)替换+的效果很好
8.x是否有突变?
我也看到这则讯息: https://code.google.com/p/android/issues/detail?id=187464
现在我将强制
p>我已经解决了这个钩子。
在您的after_platform_add中添加此脚本 >#!/ usr / bin / env node
var fs = require('fs');
var path = require('path');
var fork = require('child_process')。fork,
shell = require(shelljs);
var dir ='./platforms/android/';
fs.writeFileSync(dir +'build-extras.gradle','configurations {all * .exclude group:\'com.android.support\',module:\'support- v4 \'}','utf8');
Very weird bug appears in my Cordova project when I updated Cordova and Android SDK (all are in the last versions).
Since the update I got the following error with gradle : Error: more than one library with package name 'com.google.android.gms'
Cordova plugins have not changed and this was working well before the update. Removing/adding the Android platform or cleaning it doesn't fix this error.
It seems due to the version 8.1 of com.google.android.gms
I use the cordova-plugin-google-analytics which uses : com.google.android.gms:play-services-analytics:+ (I assume the + means last version?) Due to this line and with the update the project don't build anymore Replacing the + with a value (7.5.0, etc for example) works well
Does 8.x has a breaking change?
I saw this post too: https://code.google.com/p/android/issues/detail?id=187464
For now I will force a value but if you have a better solution you are welcome
Thanks
I have solved this with a hook. Its not perfect but works.
In your after_platform_add add this script
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var fork = require('child_process').fork,
shell = require("shelljs");
var dir = './platforms/android/';
fs.writeFileSync(dir + 'build-extras.gradle', 'configurations { all*.exclude group: \'com.android.support\', module: \'support-v4\'}', 'utf8');
这篇关于多个库名称为“com.google.android.gms”(仅为8.1)和Cordova的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!