我正在尝试在我的应用程序中使用GCM服务,但在Gradle中添加依赖项后出现此错误。 这是错误 请修改版本冲突,方法是更新google-services插件的版本(有关https://bintray.com/android/android-tools/com.google.gms.google-services/的最新版本的信息)或将com.google.android.gms的版本更新为9.0.0。
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.jimmy.chatapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support:support-vector-drawable:26.+'
implementation 'com.android.support:support-v4:26.+'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation "com.google.android.gms:play-services-gcm:15.0.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
}
Project gradle
// Top-level build file where you can add configuration options common to
all
sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
请提前帮助谢谢
答案 0 :(得分:0)
您模块的build.gradle文件的这两行使用了冲突的库版本:
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation "com.google.android.gms:play-services-gcm:15.0.0"
他们需要使用相同的版本号(12.0.1或15.0.0)。为了便于在仿真器上进行测试,除非您绝对需要最新的库版本,否则我建议使用12.0.1。
编辑:
此外,在您的项目build.gradle文件中,更新到最新的Google服务插件:
classpath 'com.google.gms:google-services:3.2.0'