【问题标题】:FCMPlugin build fail due to version conflict with google gms services由于与 google gms 服务的版本冲突,FCMPlugin 构建失败
【发布时间】:2017-02-11 13:11:05
【问题描述】:

我在适用于 Android 的 Windows 上将它与 ionic 2 一起使用。当我添加 cordova-plugin-fcm 插件时,我无法再构建项目了。这是我得到的错误:

BUILD FAILED                                                                                     

Total time: 4.697 secs                                                                           

Error: cmd: Command failed with exit code 1 Error output:                                        
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 (i
nformation 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 9.2.0.        

* Try:                                                                                           
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get mor
e log output.                                                                                    

下面是我的 config.xml 的 sn-p:

 <plugin name="cordova-plugin-console" spec="~1.0.3"/>
  <plugin name="cordova-plugin-facebook4" spec="~1.7.3">
    <variable name="APP_ID" value="XXX"/>
    <variable name="APP_NAME" value="XXX"/>
  </plugin>
  <plugin name="cordova-plugin-whitelist" spec="~1.2.2"/>
  <plugin name="cordova-plugin-statusbar" spec="~2.1.3"/>
  <plugin name="cordova-plugin-splashscreen" spec="~3.2.2"/>
  <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
  <plugin name="cordova-plugin-camera"/>
  <plugin name="cordova-plugin-geolocation" spec="https://github.com/apache/cordova-plugin-geolocation"/>
  <plugin name="cordova-plugin-googlemaps" spec="https://github.com/phonegap-googlemaps-plugin/cordova-plugin-googlemaps">
    <variable name="API_KEY_FOR_ANDROID" value="XXXX"/>
    <variable name="API_KEY_FOR_IOS" value="XXXX"/>
  </plugin>
  <plugin name="cordova-plugin-file-transfer" spec="~1.5.1"/>
  <plugin name="cordova-plugin-file" spec="~4.2.0"/>
  <plugin name="cordova-plugin-device" spec="~1.1.2"/>

我已阅读 thisthis related 的帖子,这些帖子建议将此行添加到 build.gradle(由 ionic 自动创建):

apply plugin: 'com.google.gms.google-services'

我尝试将其添加到 build-extras.gradle 中,但没有成功。

在我的 build.graddle 中,我看到了这一行:

// PLUGIN GRADLE EXTENSIONS START
apply from: "cordova-plugin-fcm/upfront-FCMPlugin.gradle"
// PLUGIN GRADLE EXTENSIONS END

还有以下几行:

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.14.+"
    compile "com.google.android.gms:play-services-maps:+"
    compile "com.google.android.gms:play-services-location:+"
    // SUB-PROJECT DEPENDENCIES END
}

我缺少什么以及如何解决此问题?

【问题讨论】:

标签: cordova ionic-framework cordova-plugins ionic2


【解决方案1】:

我解决了。

插件:

https://github.com/mauron85/cordova-plugin-background-geolocation

https://github.com/fechanique/cordova-plugin-fcm

1)。删除平台:cordova platform rm android。

2)。修改:plugins/cordova-plugin-fcm/src/android/FCMPlugin.gradle

替换:

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

与:

ext.postBuildExtras = {
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

3)添加平台:cordova平台添加android。

4) 修改:platforms/android/project.properties

将“+”改为“11.4.2”:

com.google.firebase:firebase-core:+
com.google.firebase:firebase-messaging:+
com.google.android.gms:play-services-location:+

应该是这样的:

com.google.firebase:firebase-core:11.4.2
com.google.firebase:firebase-messaging:11.4.2
com.google.android.gms:play-services-location:11.4.2

就是这样:)。

【讨论】:

  • 太棒了,为此苦苦挣扎了这么久,您的解决方案就像一个魅力。谢谢!
  • 我也遇到过同样的问题。我尝试了很多修复,但没有任何效果。最后这个灵魂给了我帮助。谢谢兄弟。
  • 我有同样的问题,但是在这样做之后会抛出许多与某些 firebase 类相关的错误。你能帮我解决这个问题吗??
【解决方案2】:

我遇到了这个线程,如果这对任何人都有帮助,这里是我所做的一组文件和更改,以便我的 android 客户端可以正常构建。我与 cordova-plugin-fcm 和 cordova-plugin-googleplus 发生冲突。这是一个

platforms/android/build.gradle

dependencies {
   classpath 'com.android.tools.build:gradle:2.2.3'
   // I added this:
   classpath 'com.google.gms:google-services:3.1.0'
}

..

allprojects {
  repositories {
   // changed the + to 10.2.0 
   compile "com.google.android.gms:play-services-auth:10.2.0"
   compile "com.google.android.gms:play-services-identity:10.2.0"
  }
}

// at end of the promptForReleaseKeyPassword function, add this:

def promptForReleaseKeyPassword() {
  ...
  apply plugin: 'com.google.gms.google-services'
}

android/project.properties(将 + 更改为 10.2.0)

cordova.system.library.3=com.google.android.gms:play-services-auth:10.2.0
cordova.system.library.4=com.google.android.gms:play-services-identity:10.2.0

cordova-plugin-fcm/mobile-FCMPlugin.gradle(这个文件很棘手)

dependencies {
  classpath 'com.android.tools.build:gradle:+'
  classpath 'com.google.gms:google-services:3.1.0'
}

...

// apply plugin: 'com.google.gms.google-services' moved into this postBuildExtras function.
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
      apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

【讨论】:

    【解决方案3】:

    要解决此错误,请转到 Project-->platform..>android-->.gradlefile 并修改该行

    buildscript {
    repositories {
            jcenter()
            mavenLocal()
        }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:3.0.0' //change this line
    }
    

    } // 应用插件:'com.google.gms.google-services' // 必须使用类而不是 id(string) 才能从非根 gradle 文件应用插件 应用插件:com.google.gms.googleservices.GoogleServicesPlugin

    【讨论】:

      【解决方案4】:

      发生了一些奇怪的事情,当我删除 google-maps 插件、构建项目并在我的设备上运行它时,一切正常,所有地图都加载得很好。

      【讨论】:

      • 看起来不像是答案
      【解决方案5】:

      我有同样的问题。原来我安装了 phonegap-plugin-push 和 cordova-plugin-fcm 。他们造成了冲突。我不得不删除其中一个。致:https://github.com/fechanique/cordova-plugin-fcm/issues/90#issuecomment-243435681

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-15
        • 2021-12-24
        • 1970-01-01
        • 2016-07-01
        相关资源
        最近更新 更多