安卓Gradle错误: 库必须使用完全相同的版本规范。发现版本28.0.0。

3

这是应用级别的依赖关系。我一直在尝试将Firebase添加到我的应用程序中,但它显示出一个错误。

apply plugin: 'com.android.application'  

    android {  
        compileSdkVersion 28  
        defaultConfig {  
            applicationId "com.example.rachitshah.fireapp"  
            minSdkVersion 15  
            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 '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'  

这是Firebase依赖项。

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

请查看以下链接:https://dev59.com/K1gQ5IYBdhLWcg3wr1_V - mohammadReza Abiri
2个回答

1
当您通过添加Gradle文件中的Firebase依赖项来添加时:
implementation 'com.google.firebase:firebase-core:16.0.1'

然后,您的应用程序中还添加了2个库。
com.android.support:support-media-compat:26.1.0
com.android.support:support-v4:26.1.0

他们的版本与28.0.0版本不同,这就是错误发生的原因。
要修复此错误,请更改您的gradle文件。
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'

    // Add this line
    implementation 'com.android.support:support-v4: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.1'
}

@RachitShah 如果你的问题已经解决,那么你应该接受这个答案。 - Son Truong
我该怎么做??我的声望不够。 - Rachit Shah
在我的答案左侧,有一个箭头图标下面带有一个勾选图标。您只需单击它即可完成。 - Son Truong

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接