【问题标题】:Please fix the version conflict error请修复版本冲突错误
【发布时间】:2018-04-25 19:55:37
【问题描述】:

我正在尝试在我的应用程序中使用 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'

}

项目分级

// 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
}

请帮忙提前谢谢

【问题讨论】:

    标签: android gradle


    【解决方案1】:

    模块的 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'
    

    【讨论】:

    • 我试过了,但是错误变成了...... ) 或将 com.google.android.gms 的版本更新为 9.0.0。
    • 我是否也需要更改这些 classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.google.gms:google-services:3.1.0'
    • @depp - 更改为 Google 服务插件的最新版本,即 3.2.0。您的 Gradle 插件版本很好。这就是我在 Android Studio 3.1 中使用的组合,它适用于 Firebase/Google 服务库的 12.0.1 或 15.0.0 版本。
    猜你喜欢
    • 2018-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多