Android 清单合并失败:使用-sdk:minSdkVersion 14
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24438170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Manifest merger failed : uses-sdk:minSdkVersion 14
提问by loeschg
Since downloading the latest SDK and installing Android Studio, my project fails to build. I get the following message:
由于下载了最新的 SDK 并安装了 Android Studio,我的项目无法构建。我收到以下消息:
Error:Gradle: Execution failed for task ':SampleProject:processProdDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
回答by loeschg
Note: This has been updated to reflect the release of API 21, Lollipop. Be sure to download the latest SDK.
注意:这已更新以反映 API 21 Lollipop 的发布。请务必下载最新的 SDK。
In one of my modules I had the following in build.gradle:
在我的一个模块中,我在 build.gradle 中有以下内容:
dependencies {
compile 'com.android.support:support-v4:+'
}
Changing this to
将此更改为
dependencies {
// do not use dynamic updating.
compile 'com.android.support:support-v4:21.0.0'
}
fixed the issue.
解决了这个问题。
Make sure you're not doing a general inclusion of com.android.support:support-v4:+
or any other support libraries (v7, v13, appcompat, etc), anywhere in your project.
确保您没有com.android.support:support-v4:+
在项目中的任何地方普遍包含或任何其他支持库(v7、v13、appcompat 等)。
I'd assume the problem is v4:+
picks up the release candidate (21.0.0-rc1)latest L release which obviously requires the L SDK.
我假设问题是v4:+
选择发布候选 (21.0.0-rc1)最新的 L 版本,这显然需要 L SDK。
Edit:
编辑:
If you need to use the new views (CardView, RecyclerView, and Palette), the following should work:
如果您需要使用新视图(CardView、RecyclerView 和 Palette),以下应该可以工作:
compile "com.android.support:cardview-v7:21.0.0"
compile "com.android.support:recyclerview-v7:21.0.0"
compile "com.android.support:palette-v7:21.0.0"
(Credit to EddieRingle on /androiddev - http://www.reddit.com/r/androiddev/comments/297xli/howto_use_the_v21_support_libs_on_older_versions/)
(归功于 /androiddev 上的 EddieRingle - http://www.reddit.com/r/androiddev/comments/297xli/howto_use_the_v21_support_libs_on_older_versions/)
Another Edit
另一个编辑
Be sure to see @murtuza's answer below regarding appcompat-v7 and upvote if it helps!
请务必在下面查看@murtuza 关于 appcompat-v7 的回答,如果有帮助,请点赞!
回答by murtuza
Also, in case you are importing the appcompat-v7 library make sure you tag a version number at the end of it like so:
此外,如果您要导入 appcompat-v7 库,请确保在其末尾标记版本号,如下所示:
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
After only changing the support-v4 version, I still received the error:
只改了 support-v4 版本后,还是报错:
Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
清单合并失败:uses-sdk:minSdkVersion 15 不能小于库 com.android.support:support-v4:21.0.0-rc1 中声明的版本 L
It was a bit confusing because it looks like v4 is still the problem, but, in fact, restricting the appcompat v7 version fixed the problem.
这有点令人困惑,因为看起来 v4 仍然是问题,但实际上,限制 appcompat v7 版本解决了问题。
回答by Gaurav Arora
Solution 1:
解决方案1:
Change uses-sdk to <uses-sdk tools:node="replace" />
and add xmlns:tools="http://schemas.android.com/tools"
in AndroidManifest.xml
更改用途-SDK来<uses-sdk tools:node="replace" />
,并添加 xmlns:tools="http://schemas.android.com/tools"
在AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.demo.android"
android:versionCode="16"
android:versionName="3.3.1">
.
.
<uses-sdk tools:node="replace" />
.
.
</manifest>
Make sure you use gradle 0.11 and above to use Manifest merger.
确保您使用 gradle 0.11 及更高版本来使用 Manifest 合并。
Solution 2:
解决方案2:
Change
compile 'com.android.support:support-v4:+'
tocompile 'com.android.support:support-v4:20.+'
inbuild.gradle
. This will prevent gradle from usingv4:21.0.0
that requires version L.However, if your any of your external dependencies uses the same. You will probably have to wait for them to update the same.
更改
compile 'com.android.support:support-v4:+'
到compile 'com.android.support:support-v4:20.+'
在build.gradle
。这将阻止使用v4:21.0.0
需要版本 L 的gradle 。但是,如果您的任何外部依赖项使用相同的。您可能必须等待他们更新相同的内容。
Solution 3:
解决方案3:
Remove/Comment
<version>21.0.0-rc1</version>
in your file<android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml
Repeat the same for support-v7
<version>21.0.0-rc1</version>
在您的文件中删除/评论<android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml
对 support-v7 重复同样的操作
回答by userM1433372
<uses-sdk tools:node="replace" />
No longer works.
不再有效。
change uses-sdk
to
更改uses-sdk
为
<uses-sdk tools:overrideLibrary="com.packagename.of.libary.with.conflict" />
and addxmlns:tools="http://schemas.android.com/tools"
in the AndroidManifest.xml file
并xmlns:tools="http://schemas.android.com/tools"
在 AndroidManifest.xml 文件中添加
回答by koesclem
The problem still arises with transitive dependencies. Gradle offers a way to force the usage of a specific version of a dependency.
问题仍然存在于传递依赖中。Gradle 提供了一种强制使用特定版本依赖项的方法。
For example you can add something like:
例如,您可以添加如下内容:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:20.+'
force 'com.android.support:appcompat-v7:20.+'
}
}
to your build.gradle.
到你的 build.gradle。
If you want to learn more about gradle resolution strategies refer to this guide http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
如果您想了解有关 gradle 解析策略的更多信息,请参阅本指南http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
I found this while reading the corresponding issue which I will link here
我在阅读相应的问题时发现了这一点,我将在此处链接
回答by Bhargav Jhaveri
In the build.gradle file, It was by default compile 'com.android.support:support-v4:+' so when you build the gradle projecit would consider, com.android.support:support-v4:21.0.0-rc1 because of the recent L developer preview release.
在 build.gradle 文件中,默认情况下编译 'com.android.support:support-v4:+' 所以当你构建 gradle 项目时会考虑,com.android.support:support-v4:21.0.0-rc1因为最近的 L 开发者预览版。
Make changes in the following line and it will resolve the issue. Change
在以下行中进行更改,它将解决问题。改变
compile 'com.android.support:support-v4:+'
to
到
compile 'com.android.support:support-v4:20.+'
Similarly when using v7-appcompat support library, make the change from
同样,当使用 v7-appcompat 支持库时,从
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:appcompat-v7:+'
to
到
compile 'com.android.support:appcompat-v7:20.+'.
回答by Leonardo Cardoso
Adding to the correct answers above, the problem still might occur due to library nesting. In this case, try as the example below:
加上上面的正确答案,由于库嵌套,问题仍然可能发生。在这种情况下,请尝试以下示例:
compile 'com.android.support:support-v4:20.+'
compile ('com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+') { // example
exclude group: 'com.android.support', module:'support-v4'
exclude group: 'com.android.support', module:'appcompat-v7'
}
回答by ProllyGeek
for people building hybrid apps using cordova CLI, this command will help:
对于使用cordova CLI 构建混合应用程序的人,此命令将有所帮助:
cordova build android -- --minSdkVersion=15
yes it uses double double dashes as you saw it.
是的,正如您所见,它使用双双破折号。
回答by Illegal Argument
For people facing this issue in the Android Studiobeta, the accepted answer didn't solve my problem. Importing a project downloaded from GitHub, I had the following in my build.gradle file of app giving an error in question:
对于在Android Studio测试版中遇到此问题的人,接受的答案并没有解决我的问题。导入从 GitHub 下载的项目,我在应用程序的 build.gradle 文件中有以下内容,给出了一个有问题的错误:
dependencies {
compile 'com.android.support:support-v4:+'
}
But in my external library folder I have this folder:
但是在我的外部库文件夹中,我有这个文件夹:
support-v4-21.0.0-rc1 //note the 21
I solved the above problem by changing the dependency to:
我通过将依赖项更改为:
dependencies {
compile 'com.android.support:support-v4:20.+' //20 used less than available strange but works
}
Note: you might also need to download api level lower than the currently available in Android Studio for some library and projects for this to work properly.
注意:您可能还需要为某些库和项目下载比 Android Studio 中当前可用的 api 级别更低的 api 级别,以使其正常工作。
回答by min2bro
I also had the same issue and changing following helped me:
我也遇到了同样的问题,更改以下内容对我有帮助:
from:
从:
dependencies {
compile 'com.android.support:support-v4:+'
to:
到:
dependencies {
compile 'com.android.support:support-v4:20.0.0'
}