错误:请修复版本冲突?

时间:2018-04-06 06:20:22

标签: java android

虽然使用依赖关系会在 google-services插件 com.google.android.gms 上显示错误。如何解决此问题?

build.gradle(模块应用)

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'

implementation 'com.twotoasters.jazzylistview:library:1.2.1'

implementation 'com.google.android.gms:play-services-ads:12.0.1'
//here its shows an error

请通过更新 google-services 插件的版本(https://bintray.com/android/android-tools/com.google.gms.google-services/提供有关最新版本的信息)或更新 com的版本来解决版本冲突.google.android.gms 至12.0.1。

implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'

build.gradle(Project XYZ)

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'
   // classpath 'com.google.gms:google-services:3.0.0'
    classpath 'com.google.gms:google-services:3.2.0' // google-services plugin
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

 allprojects {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
  }

   task clean(type: Delete) {
    delete rootProject.buildDir
 }

2 个答案:

答案 0 :(得分:3)

您需要使用相同版本的依赖项

使用此

implementation 'com.google.firebase:firebase-messaging:12.0.1'

而不是这个

implementation 'com.google.firebase:firebase-messaging:11.0.4'

答案 1 :(得分:2)

依赖项应该是相同的版本。否则会出现冲突错误。

替换此

implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:11.0.4'

implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'