【问题标题】:Google GCM with Cordova error带有 Cordova 错误的 Google GCM
【发布时间】:2015-12-22 08:32:58
【问题描述】:

添加后,Cordova GCM push plugins 我的构建遇到了一些问题,并确实解决了这个问题,如thread 所示。

最近,构建又开始失败了,除了这个例外:

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 中指定了一个与此类似的错误。如上所述,我已经指定了版本,更新了我的构建工具,播放了服务 repo。

【问题讨论】:

    标签: android cordova gradle google-cloud-messaging


    【解决方案1】:

    我在使用另一个插件时遇到过这个问题,我用 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');
    }
    

    希望对你有帮助

    【讨论】:

    • 我可以直接将此配置添加到 build-extras.gradle。但我会试试你的方法。但主要是针对多个 dex 文件,对吧?
    • 它不工作!我使用的 Facebook 连接插件抛出了一些错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 2017-02-09
    • 1970-01-01
    相关资源
    最近更新 更多