【问题标题】:Ionic Android : Error of version conflict of gcm services while adding FCM pluginIonic Android:添加 FCM 插件时 gcm 服务的版本冲突错误
【发布时间】:2017-10-19 23:30:26
【问题描述】:
【问题讨论】:
标签:
android-studio
ionic-framework
【解决方案1】:
如果是 Cordova OR Ionic App
在集成 Firebase 云消息传递 (FCM) 后,我的 ionic 1 cordova 版本存在类似问题
错误信息
构建失败
总时间:1.605 秒
错误:/Users/beo-administrator/Documents/projects/Apps/Ionic/psc/platforms/android/gradlew:命令失败,退出代码 1 错误输出:
FAILURE:构建失败并出现异常。
解决方案
我通过以下步骤解决了这个问题
所以一个解决方法是:在 platforms/android 打开 project.properties(它是一个文件),你会得到这样的东西
cordova.system.library.1=com.google.android.gms:play-services-ads:+
cordova.system.library.2=com.google.firebase:firebase-core:+
cordova.system.library.3=com.google.firebase:firebase-messaging:+
替换
+
使用您的目标版本号签名 - 如下所示
cordova.system.library.1=com.google.android.gms:play-services-ads:9.0.0
cordova.system.library.2=com.google.firebase:firebase-core:9.0.0
cordova.system.library.3=com.google.firebase:firebase-messaging:9.0.0
保存文件
然后使用
进行构建
ionic cordova run android
【解决方案2】:
Go to platforms > android > android build.gradle and add below three lines in dependencies area
compile "com.google.firebase:firebase-core:9.0.0"
compile "com.google.firebase:firebase-messaging:9.0.0"
compile "com.google.android.gms:play-services-gcm:9.0.0"
Now your update dependencies looks like as-
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
// SUB-PROJECT DEPENDENCIES START
debugCompile project(path: 'CordovaLib', configuration: 'debug')
releaseCompile project(path: 'CordovaLib', configuration: 'release')
compile 'com.android.support:support-v4:23.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.14.+'
// compile 'com.google.firebase:firebase-core:+'
// compile 'com.google.firebase:firebase-messaging:+'
// SUB-PROJECT DEPENDENCIES END
compile files('libs/twitter4j-core-4.0.2.jar')
compile 'com.google.code.gson:gson:2.8.0'
compile "com.google.firebase:firebase-core:9.0.0"
compile "com.google.firebase:firebase-messaging:9.0.0"
compile "com.google.android.gms:play-services-gcm:9.0.0"
}
【解决方案3】:
转到平台 > android > cordova-plugin-fcm。找到看起来像 FCMPlugin.gradle 的文件。
然后改成:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0' // change this line
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
来源:
https://stackoverflow.com/a/44039853/8037833
【解决方案4】:
遇到了同样的问题,其他答案对我不起作用。(在构建时 build.gradle 得到了编辑,版本 nr 返回到以前的 nr。)
我已经通过编辑platforms/android/中的project.properties文件来修复它
target=android-25
android.library.reference.1=CordovaLib
cordova.gradle.include.1=com-sarriaroman-photoviewer/starter-photoviewer.gradle
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v13:25.1.0
cordova.system.library.3=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.4=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.2=phonegap-plugin-push/starter-push.gradle
cordova.system.library.5=com.google.android.gms:play-services-base:11.0.1
cordova.system.library.6=com.google.android.gms:play-services-ads:11.0.1
确保有相同版本的com.google.android.gms