2015-12-22 244 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