Firebase版本与支持库冲突

时间:2019-04-09 04:38:39

标签: android firebase gradle

我知道这是一个常见问题,我已经阅读了几篇文章,并多次修改了gradle文件,但找不到解决方法。

  

错误消息是:所有com.android.support库都必须使用   完全相同的版本规范。找到版本28.0.0、26.1.0。

但是我不知道26.1.0的版本在哪里。知道如何解决吗?

这是我的 build.gradle(module:app)

  apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'

  android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.emojify_kotlin"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
  }

  dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    implementation 'com.google.firebase:firebase-core:16.0.8'
 }

 apply plugin: 'com.google.gms.google-services'

这是我的项目gradle文件

buildscript {
ext.kotlin_version = '1.3.21'
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
    classpath 'com.google.gms:google-services:4.2.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // 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}

3 个答案:

答案 0 :(得分:1)

使用gradle app:dependencies,获取依赖项列表:

 +--- org.jetbrains.kotlin:kotlin-stdlib-jre7:..
|    \--- org.jetbrains.kotlin:kotlin-stdlib:..
|         \--- org.jetbrains:annotations:...
+--- com.google.firebase:firebase-core:16....
|    +--- com.google.firebase:firebase-analytics:16...
|    |    +--- com.google.android.gms:play-services-basement:15....
|    |    |    \--- com.android.support:support-v4:26.1.0
|    |    |         +--- com.android.support:support-compat:26.1.0 ->.......

它显示Firebase需要com.android.support:support-v4:26.1.0,因此您必须覆盖它 与 com.android.support:support-v4:28.0.0

答案 1 :(得分:0)

更改

dependencies{
implementation 'com.google.firebase:firebase-core:16.0.8'
}

对您的应用的依赖来自于

dependencies{
   implementation 'com.google.firebase:firebase-core:15.0.0'
}

,然后将您的项目与这些更改同步。

答案 2 :(得分:0)

覆盖您的Firebase依赖项
  com.android.support:support-v4:26.1.0

快乐编码:)