由于Firebase库,支持库版本冲突 [英] Conflicting versions of the support library because of the Firebase library

查看:83
本文介绍了由于Firebase库,支持库版本冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio中创建新项目后,我在该项目中添加了Firebase和Firebase消息,如手册.

After creating a new project in Android Studio, I added Firebase and Firebase-messaging to the project, as described in the manual.

但是,在Gradle同步之后,IDE会显示错误:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-beta01, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-beta01 and com.android.support:support-media-compat:26.1.0

However, after Gradle sync, the IDE displays an error:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-beta01, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-beta01 and com.android.support:support-media-compat:26.1.0

没有Firebase库,则项目构建正确.

Without Firebase libraries, the project is built correctly.

项目级build.gradle:

Project-level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        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
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

模块级build.gradle:

Module-level build.gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "ru.sabernyan.myapplication"
        minSdkVersion 16
        targetSdkVersion 28
        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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'

    implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'

    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.android.support:design:28.0.0-beta01'
}

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

其余文件未更改.

版本:

Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.17.11-zen1

推荐答案

使用gradle app:dependencies,我得到了依赖项列表:

Using gradle app:dependencies, I got a list of dependencies:

debugCompileClasspath - Resolved configuration for compilation for variant: debug
+--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.30
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.30
|         \--- org.jetbrains:annotations:13.0
+--- com.google.firebase:firebase-core:16.0.1
|    +--- com.google.firebase:firebase-analytics:16.0.1
|    |    +--- com.google.android.gms:play-services-basement:15.0.1
|    |    |    \--- com.android.support:support-v4:26.1.0
|    |    |         +--- com.android.support:support-compat:26.1.0 -> 28.0.0-beta01
|    |    |         |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    +--- com.android.support:collections:28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    +--- android.arch.lifecycle:runtime:1.1.1
|    |    |         |    |    +--- android.arch.lifecycle:common:1.1.1
|    |    |         |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0-beta01
|    |    |         |    |    +--- android.arch.core:common:1.1.1
|    |    |         |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0-beta01
|    |    |         |    \--- com.android.support:versionedparcelable:28.0.0-beta01
|    |    |         |         \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         +--- com.android.support:support-media-compat:26.1.0 -> 28.0.0-beta01
|    |    |         |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    \--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         +--- com.android.support:support-core-utils:26.1.0 -> 28.0.0-beta01
|    |    |         |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:documentfile:28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    +--- com.android.support:loader:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|    |    |         |    |    |    +--- android.arch.lifecycle:common:1.1.1 (*)
|    |    |         |    |    |    +--- android.arch.core:common:1.1.1 (*)
|    |    |         |    |    |    \--- android.arch.core:runtime:1.1.1
|    |    |         |    |    |         +--- com.android.support:support-annotations:26.1.0 -> 28.0.0-beta01
|    |    |         |    |    |         \--- android.arch.core:common:1.1.1 (*)
|    |    |         |    |    \--- android.arch.lifecycle:viewmodel:1.1.1
|    |    |         |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0-beta01
|    |    |         |    +--- com.android.support:localbroadcastmanager:28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    \--- com.android.support:print:28.0.0-beta01
|    |    |         |         \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         +--- com.android.support:support-core-ui:26.1.0 -> 28.0.0-beta01
|    |    |         |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:support-core-utils:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:customview:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:viewpager:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    |    \--- com.android.support:customview:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:coordinatorlayout:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    |    \--- com.android.support:customview:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:drawerlayout:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    |    \--- com.android.support:customview:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:slidingpanelayout:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    |    \--- com.android.support:customview:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:interpolator:28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    +--- com.android.support:swiperefreshlayout:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    |    \--- com.android.support:interpolator:28.0.0-beta01 (*)
|    |    |         |    +--- com.android.support:asynclayoutinflater:28.0.0-beta01
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         |    |    \--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |         |    \--- com.android.support:cursoradapter:28.0.0-beta01
|    |    |         |         \--- com.android.support:support-annotations:28.0.0-beta01
|    |    |         \--- com.android.support:support-fragment:26.1.0 -> 28.0.0-beta01
|    |    |              +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    |    |              +--- com.android.support:support-core-ui:28.0.0-beta01 (*)
|    |    |              +--- com.android.support:support-core-utils:28.0.0-beta01 (*)
|    |    |              +--- com.android.support:support-annotations:28.0.0-beta01
|    |    |              +--- com.android.support:loader:28.0.0-beta01 (*)
|    |    |              \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
|    |    +--- com.google.android.gms:play-services-measurement-base:[16.0.0] -> 16.0.0
|    |    +--- com.google.android.gms:play-services-stats:15.0.1
|    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
|    |    +--- com.google.firebase:firebase-analytics-impl:[16.1.1] -> 16.1.1
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:15.0.1
|    |    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:[16.0.0] -> 16.0.0
|    |    |    +--- com.google.android.gms:play-services-stats:15.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:15.0.1
|    |    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
|    |    |    +--- com.google.firebase:firebase-common:16.0.0
|    |    |    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    |    |    \--- com.google.android.gms:play-services-tasks:15.0.1 (*)
|    |    |    \--- com.google.firebase:firebase-iid:16.0.0 -> 16.2.0
|    |    |         +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    |         +--- com.google.android.gms:play-services-stats:15.0.1 (*)
|    |    |         +--- com.google.android.gms:play-services-tasks:15.0.1 (*)
|    |    |         +--- com.google.firebase:firebase-common:16.0.0 (*)
|    |    |         \--- com.google.firebase:firebase-iid-interop:16.0.0
|    |    |              +--- com.google.android.gms:play-services-base:15.0.1
|    |    |              |    +--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
|    |    |              |    \--- com.google.android.gms:play-services-tasks:[15.0.1] -> 15.0.1 (*)
|    |    |              \--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    \--- com.google.firebase:firebase-common:16.0.0 (*)
|    \--- com.google.firebase:firebase-measurement-connector-impl:16.0.1
|         +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|         +--- com.google.android.gms:play-services-measurement-base:[16.0.0] -> 16.0.0
|         +--- com.google.firebase:firebase-analytics:[16.0.1] -> 16.0.1 (*)
|         +--- com.google.firebase:firebase-analytics-impl:[16.1.1] -> 16.1.1 (*)
|         +--- com.google.firebase:firebase-common:16.0.0 (*)
|         \--- com.google.firebase:firebase-measurement-connector:16.0.0
|              \--- com.google.android.gms:play-services-basement:15.0.1 (*)
+--- com.google.firebase:firebase-messaging:17.1.0
|    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    +--- com.google.android.gms:play-services-tasks:15.0.1 (*)
|    +--- com.google.firebase:firebase-common:16.0.0 (*)
|    +--- com.google.firebase:firebase-iid:[16.2.0] -> 16.2.0 (*)
|    \--- com.google.firebase:firebase-measurement-connector:16.0.0 (*)
+--- com.android.support:appcompat-v7:28.0.0-beta01
|    +--- com.android.support:support-annotations:28.0.0-beta01
|    +--- com.android.support:support-compat:28.0.0-beta01 (*)
|    +--- com.android.support:collections:28.0.0-beta01 (*)
|    +--- com.android.support:cursoradapter:28.0.0-beta01 (*)
|    +--- com.android.support:support-core-utils:28.0.0-beta01 (*)
|    +--- com.android.support:support-fragment:28.0.0-beta01 (*)
|    +--- com.android.support:support-vector-drawable:28.0.0-beta01
|    |    +--- com.android.support:support-annotations:28.0.0-beta01
|    |    \--- com.android.support:support-compat:28.0.0-beta01 (*)
|    \--- com.android.support:animated-vector-drawable:28.0.0-beta01
|         +--- com.android.support:support-vector-drawable:28.0.0-beta01 (*)
|         \--- com.android.support:support-core-ui:28.0.0-beta01 (*)
+--- com.android.support:support-media-compat:28.0.0-beta01 (*)
+--- com.android.support.constraint:constraint-layout:1.1.2
|    \--- com.android.support.constraint:constraint-layout-solver:1.1.2
\--- com.android.support:design:28.0.0-beta01
     +--- com.android.support:support-annotations:28.0.0-beta01
     +--- com.android.support:support-compat:28.0.0-beta01 (*)
     +--- com.android.support:support-core-ui:28.0.0-beta01 (*)
     +--- com.android.support:support-core-utils:28.0.0-beta01 (*)
     +--- com.android.support:support-fragment:28.0.0-beta01 (*)
     +--- com.android.support:transition:28.0.0-beta01
     |    +--- com.android.support:support-annotations:28.0.0-beta01
     |    \--- com.android.support:support-compat:28.0.0-beta01 (*)
     +--- com.android.support:appcompat-v7:28.0.0-beta01 (*)
     +--- com.android.support:cardview-v7:28.0.0-beta01
     |    \--- com.android.support:support-annotations:28.0.0-beta01
     \--- com.android.support:recyclerview-v7:28.0.0-beta01
          +--- com.android.support:support-annotations:28.0.0-beta01
          +--- com.android.support:support-compat:28.0.0-beta01 (*)
          \--- com.android.support:support-core-ui:28.0.0-beta01 (*)

它表明Firebase提取了依赖项com.android.support:support-v4:26.1.0,所以我将其覆盖,并且我的build.gradle现在看起来像这样:

It shows that Firebase pulls the dependency com.android.support:support-v4:26.1.0, so I overwritten it, and my build.gradle now looks like this:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "ru.sabernyan.myapplication"
        minSdkVersion 16
        targetSdkVersion 28
        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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'

    implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
    implementation 'com.android.support:support-v4:28.0.0-beta01' // <= dependency overwritten
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'

    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.android.support:design:28.0.0-beta01'
}

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

而且有效!

这篇关于由于Firebase库,支持库版本冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆