More than one library with package name 'com.google.android.gms' (only 8.1) and Cordova

房东的猫 提交于 2019-12-25 14:23:14

问题


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


回答1:


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');


来源:https://stackoverflow.com/questions/32874223/more-than-one-library-with-package-name-com-google-android-gms-only-8-1-and

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