Cordova 由于版本与google gms服务冲突,FCMPlugin构建失败
我在Windows for Android上使用的是ionic 2。当我添加cordova插件fcm插件时,我无法再构建该项目。下面是我得到的错误:Cordova 由于版本与google gms服务冲突,FCMPlugin构建失败,cordova,ionic-framework,cordova-plugins,ionic2,Cordova,Ionic Framework,Cordova Plugins,Ionic2,我在Windows for Android上使用的是ionic 2。当我添加cordova插件fcm插件时,我无法再构建该项目。下面是我得到的错误: BUILD FAILED Total time: 4.697 secs
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.
下面是my config.xml的一个片段:
<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"/>
还有以下几行:
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
}
我遗漏了什么以及如何解决此问题?我也有同样的问题。结果我安装了phonegap插件push和cordova插件fcm。他们是冲突的始作俑者。我不得不移除其中一个。归功于:当我删除谷歌地图插件,构建项目并在我的设备上运行时,一切都很顺利,所有地图都加载得很好 若要解决此错误,请转到项目-->平台..>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.googleservices”
//类而不是id(字符串)才能从非根gradle文件应用插件
apply plugin:com.google.gms.googleservices.GoogleServicesPlugin我遇到了这个线程,如果这对任何人都有帮助,下面是我所做的一组文件和更改,以便我的android客户端能够很好地构建。我与cordova插件fcm和cordova插件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插件fcm/mobile-FCMPlugin.gradle(这个文件很棘手)
我解决了
插件:
1) 。移除平台:cordova平台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:11.4.2
com.google.firebase:firebase-messaging:11.4.2
com.google.android.gms:play-services-location:11.4.2
仅此而已:) 你找到这个问题的解决方案了吗?@Astrowie:没有,但你可以使用另一个插件:看,它看起来不像是答案。真棒,在这个问题上挣扎了这么久,你的解决方案很有魅力。谢谢我也面临同样的问题。我尝试了很多修复方法,但都没有效果。最后这个灵魂帮了我一把。谢谢兄弟。我也有同样的问题,但在做了这件事之后,有很多与firebase类相关的错误。你能帮我解决吗??
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
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