Android Studio收到警告警告支持:appcompat-v7:28.0.0

时间:2019-03-14 05:09:26

标签: android android-gradle

我在 build.gradle 文件中出现错误

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1) 
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

这是我的gradle文件

android {
            compileSdkVersion 28
            defaultConfig {
                applicationId "com.pristology.mysociety"
                minSdkVersion 15
                targetSdkVersion 28
                versionCode 3
                versionName "1.0.3"
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
                }
            }
        }
            implementation fileTree(dir: 'libs', include: ['*.jar'])
            implementation 'com.android.support:appcompat-v7:28.0.0'

            implementation 'com.android.support:design: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.android.support:cardview-v7:28.0.0'

更新android studio 3.3.2时,我在应用程序级别的gradle文件中收到警告

2 个答案:

答案 0 :(得分:2)

  

所有com.android.support库必须使用完全相同的版本规范

发生这种情况是因为您的某些库使用了旧版本support-media-compat

只需在依赖项中显式添加库的版本

implementation 'com.android.support:support-media-compat:28.0.0'

答案 1 :(得分:-1)

1st)由于appcompat版本不同,您遇到了问题,请更改您的 依赖,因为在gradle版本3. +中会导致问题

> implementation 'com.android.support:appcompat-v7:28.0.0'

此版本

implementation 'com.android.support:appcompat-v7:28.0.0'-alpha1

或者您可以使用v7:27.1.1,但是您必须在app:gradle的任何地方进行更改

2nd)如果您使用的是Firebase,那么也会引起问题,因此请删除此行代码

implementation 'com.google.firebase:firebase-core:16.0.7'

因为此行不是必需的,您将摆脱此问题;)