gpt4 book ai didi

Android:更新到新版本的 gradle 后出现 "Manifest merger failed"错误

转载 作者:IT老高 更新时间:2023-10-28 13:04:04 25 4
gpt4 key购买 nike

接受将项目更新到新版本的 gradle 后,我收到此错误:

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:cardview-v7:26.0.0-alpha1] AndroidManifest.xml:24:9-38
is also present at [com.android.support:design:25.3.1] AndroidManifest.xml:27:9-31 value=(25.3.1).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:22:5-24:41 to override.

我该如何解决这个问题?这是我应用的 build.gradle 文件:

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.sample.bookReader"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
...
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:+'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:design:25+'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
...
}

这是项目的build.gradle:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}

allprojects {
repositories {
jcenter()
maven { url "https://www.jitpack.io" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

如何在保持通过更新 gradle 版本所做的更改的同时修复此错误?

最佳答案

把它放在你的应用模块 build.gradle 的末尾:

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}

归功于 Eugen Pechanec

关于Android:更新到新版本的 gradle 后出现 "Manifest merger failed"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43280871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com