为CardView添加库时出错

时间:2018-07-05 07:46:49

标签: android android-studio build.gradle android-cardview

当我在我的build.gradle(Module:app)文件中添加CardView库(“ compile'c​​om.android.support:cardview-v7:25.3.1'”)时,显示错误

请帮助我!

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "in.trysafe.trysafecfs"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

它向我显示此错误:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value 
value=(26.0.0-alpha1) from [com.android.support:design:26.0.0-alpha1] 
AndroidManifest.xml:27:9-38
    is also present at [com.android.support:cardview-v7:25.3.1] 
AndroidManifest.xml:24:9-31 value=(25.3.1).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at 
AndroidManifest.xml:25:5-27:41 to override.

2 个答案:

答案 0 :(得分:2)

更改您的

UInt64

compile 'com.android.support:cardview-v7:25.3.1'

因为所有支持库都应为同一版本

答案 1 :(得分:0)

使用完全相同的依赖版本,而不是26.+

compile 已弃用

还使用 implementation 代替 compile

尝试一下

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'

比您的项目 clean - Re-Build - Run