首页 > 解决方案 > Build.Gradle 中的库版本错误

问题描述

如果我添加implementation 'com.google.android.gms:play-services-analytics:16.0.1' 到我的应用程序 build.gradle 我在该行和implementation 'com.android.support:appcompat-v7:27.1.1'

All com.android.support libraries must use the exact same version 
specification (mixing versions can lead to runtime crashes). Found versions
 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-
drawable:27.1.1 and com.android.support:support-media-compat:26.1.0

All gms/firebase libraries must use the exact same version specification 
(mixing versions can lead to runtime crashes). Found versions 16.0.1, 16.0.0,
 15.0.1. Examples include com.google.android.gms:play-services-
analytics:16.0.1 and com.google.android.gms:play-services-measurement-
base:16.0.0 

我怎么解决这个问题??我试图手动编辑库的版本,但我仍然遇到同样的问题。

这是我的 Build.Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.domain.app"
        minSdkVersion 15
        targetSdkVersion 27
        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:27.1.1'

    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'

    compile 'com.android.support:recyclerview-v7:27.1.1'
    compile 'com.android.support:cardview-v7:27.1.1'
    compile 'com.facebook.stetho:stetho:1.4.2'

    implementation 'com.google.android.gms:play-services-analytics:16.0.1'



}

标签: androidgradle

解决方案


更改所有Gradle文件(包括导入的项目)中的库版本。之后清理并重建项目。如果您仍然收到错误,请忽略它,因为它不会影响您的应用程序。


推荐阅读