为 CardView 添加库时出错



当我在我的build.gradle(模块:应用程序(文件中添加CardView的库("编译'com.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.

更改您的

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

compile 'com.android.support:cardview-v7:26.+'

因为所有支持库都应该是相同的版本

使用完全相同的依赖项版本而不是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您的项目

最新更新