2015-12-22 246 views
1

添加后,Cordova GCM push plugins我遇到了几个与我的构建问题,并确实解决了这个thread谷歌GCM与科尔多瓦错误

近日,构建开始再次失败,与此异常:

Found com.google.android.gms:play-services-location:+, but version 8.3.0 is needed for the google-services plugin. 
:processDebugGoogleServices FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':processDebugGoogleServices'. 
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0. 

我认为,这是来自从build.gradle文件中的以下内platform/android

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    // SUB-PROJECT DEPENDENCIES START 
    debugCompile project(path: "CordovaLib", configuration: "debug") 
    releaseCompile project(path: "CordovaLib", configuration: "release") 
    compile "com.facebook.android:facebook-android-sdk:4.+" 
    compile "com.google.android.gms:play-services-location:+" // This line in particular 
    // SUB-PROJECT DEPENDENCIES END 
} 

这是不可能的编辑此文件直接,因此我创建了build-extras.gradle文件:

configurations.all{ 
    resolutionStrategy{ 
     force ("com.google.android.gms:play-services-location:8.3.0") 
    } 
} 

但我无法解决它。如上所述,我仍然遇到同样的错误。

Google在8.3 release notes中指定了与此类似的错误。如上所述,我已经指定了版本,更新了我的构建工具,播放服务回购。

回答

0

我曾面临与其他插件的问题,我在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/'; 
if (fs.existsSync(dir)){ 
    fs.writeFileSync(dir + 'build-extras.gradle', 'configurations { all*.exclude group: \'com.android.support\', module: \'support-v4\'}', 'utf8'); 
} 

希望帮助

+0

我可以直接添加该配置建立,extras.gradle。但我会尝试你的方法。但主要是这是为了多个dex文件,对吧? – InfinitePrime

+0

它不工作!我使用的Facebook连接插件正在抛出一些错误。 – InfinitePrime