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
310
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.
确保你没有做一个通用的。android。支持:supportv4:+或任何其他支持库(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 -rc1),这显然需要L SDK。
Edit:
编辑:
If you need to use the new views (CardView, RecyclerView, and Palette), the following should work:
如果您需要使用新的视图(CardView、clerview和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/)
(Credit to EddieRingle on /androiddev - http://www.reddit.com/r/androiddev/comments/297xli/howto_use_the_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和upvote的答案,如果它有帮助的话!
69
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
Manifest合并失败:us -sdk:minSdkVersion 15不能小于在library com.android.support中声明的版本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版本解决了这个问题。
54
Solution 1:
解决方案1:
Change uses-sdk to
and add xmlns:tools="http://schemas.android.com/tools"
in AndroidManifest.xml
将uses-sdk更改为
.
.
.
.
Make sure you use gradle 0.11 and above to use Manifest merger.
请确保您使用的是0.11和以上,以使用清单合并。
Solution 2:
解决方案2:
Change compile 'com.android.support:support-v4:+'
to compile 'com.android.support:support-v4:20.+'
in build.gradle
. This will prevent gradle from using v4:21.0.0
that requires version L.
改变编译的com.android。支持:support-v4:+“编译”com.android.support:support-v4:20。在build.gradle +”。这将防止gradle使用需要版本L的v4:21.0.0。
However, if your any of your external dependencies uses the same. You will probably have to wait for them to update the same.
但是,如果您的任何外部依赖项使用相同的方法。您可能需要等待它们更新相同的内容。
Solution 3:
解决方案3:
Remove/Comment
in your file
在你的文件中,删除/评论<> .0.0 .0-rc1, /extras/android/m2repository/ m2repository/ supportv4/maven-metadata.xml。
Repeat the same for support-v7
对supportv7重复同样的操作。
20
no longer works.
不再有效。
Change uses-sdk to
改变uses-sdk
and add xmlns:tools="http://schemas.android.com/tools" in AndroidManifest.xml
并在AndroidManifest.xml中添加xmlns:tools="http://schemas.android.com/tools"。
11
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
如果你想了解更多关于渐变的策略,请参考下面的指南:http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.resolution .html。
I found this while reading the corresponding issue which I will link here
我在阅读相关的问题时发现了这个问题。
8
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.
在构建。gradle文件,它是默认编译'com.android。支持:supportv4:+'所以当你构建一个gradle项目时,com.android.support:support-v4:21.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:+'
编译的com.android.support:appcompat-v7:+
to
来
compile 'com.android.support:appcompat-v7:20.+'.
8
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'
}
6
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'
}
6
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.
是的,它使用的是双双破折号。
6
For people facing this issue in the Android Studio beta, 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 beta中面临这个问题的人来说,接受的答案并不能解决我的问题。导入从GitHub下载的项目,我在构建中有如下内容。应用程序的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.
注意:您可能还需要下载api级别低于目前在Android Studio中提供的一些库和项目,以使其正常工作。
5
I solved the problem by editing the line below in build.gradle and it works! :-)
我通过编辑下面的代码来解决这个问题。它和它的工作原理!:-)
adding version 20.+'
添加版本20。+ '
From
从
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
To
来
dependencies {
compile 'com.android.support:appcompat-v7:20.+'
}
4
You have to configure all the supports and appcompat libraries with version 19.+
您必须配置所有支持和appcompat库与版本19.+。
If the recommendation of leave the support library with the 19.+ version doesn't works you can try the next tip in your AndroidManifest file.
如果推荐离开支持库与19。+版本没有效果,你可以在AndroidManifest文件中尝试下一个提示。
First add this code:
第一次添加此代码:
xmlns:tools="http://schemas.android.com/tools"
And then, at the application level (not inside application!)
然后,在应用程序级别(不在应用程序内!)
4
I make all of the solutions in here with no result, so i look in another place and i found a way to trick the IDE, so you have to put a line in the Mainfest to make the Gradle use a different one, the one that you put on build.gradle the line is:
我让所有的解决方案在这里没有结果,所以我在另一个地方看,我发现了一个方法技巧IDE,所以你必须把线放在Mainfest Gradle使用一个不同的人,你戴上构建。gradle线路是:
just it, and it work.
就是这样,而且还有效。
I hope it helps.
我希望它有帮助。
4
compile('com.android.support:support-v4:19.1.0'){
force = true
}
Helped me, taken from here
帮助我,从这里带走。
3
You need to remove from build.gradle compile 'com.android.support:support-v13:+'
您需要从构建中移除。gradle编译的com.android.support:support-v13:+
3
Here's the new bug filed for this btw https://code.google.com/p/android/issues/detail?id=72430
这里有一个新的bug,它是针对这个btw的https://code.google.com/p/android/addrees/detail? id=72430。
Assuming you are using the Support Repository, the workaround is to comment or remove the line
假设您正在使用支持存储库,那么解决方案是注释或删除该行。
21.0.0-rc1 in the local Maven repo listing file at /extras/android/m2repository/com/android/support-v4/maven-metadata.xml
在本地的Maven repo列表文件中,在/extras/android/m2repository/ support-v4/maven-metadata.xml中。
0
Don't forget, you should edit build.gradle in 'app' subfolder of your project, not in project's folder. I've lost a working day trying to solve a problem with version "L".
别忘了,你应该编辑build。在你的项目的“应用程序”的子文件夹中,而不是在项目的文件夹中。我已经失去了一个工作日,试图解决一个版本“L”的问题。
0
Try deleting the build folder(s) in your project and resync your gradle project to rebuild it. Also, like others have said in this post - instead of doing something like this:
尝试删除项目中的构建文件夹,并重新同步您的gradle项目来重新构建它。而且,就像其他人在这篇文章中所说的那样:
compile 'com.android.support:support-v4:19.+'
do this:
这样做:
compile 'com.android.support:support-v4:19.1.0'
0
Thank you @Murtuza. Your answer helped me to solve my problem but in my case
谢谢你@Murtuza。你的回答帮助我解决了问题,但在我的情况下。
compile 'com.android.support:support-v13:19.+
also, along with
编译的com.android.support:support-v13:19。+,连同
compile 'com.android.support:support-v4:19.+' compile 'com.android.support:appcompat-v7:19.+'
编译的com.android.support:support-v4:19。+“编译”com.android.support:appcompat-v7:19。+ '
from compile 'com.android.support:support-v4:+' compile 'com.android.support:support-v7:+' compile 'com.android.support:support-v13:+'
Hope this might help some one
从编译的com.android。支持:support-v4:+ com.android“编译”。支持:support-v7:+ com.android“编译”。支持:supportv13:+“希望这能帮助一些人。”
0
I have some projects where I prefer to target L.MR1(SDKv22) and some projects where I prefer KK(SDKv19). Your result may be different, but this worked for me.
我有一些项目,我更喜欢使用lmr1 (SDKv22)和一些我喜欢KK(SDKv19)的项目。你的结果可能不一样,但这对我很有效。
// Targeting L.MR1 (Android 5.1), SDK 22
android {
compileSdkVersion 22
buildToolsVersion "22"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// google support libraries (22)
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
}
// Targeting KK (Android 4.4.x), SDK 19
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// google libraries (19)
compile 'com.android.support:support-v4:19.1+'
compile 'com.android.support:appcompat-v7:19.1+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
}
0
In Android Studio 1.1.0: File - Project Structure - Tab Flavors - Select Min SDK Version which is higher than in Manifest
在Android Studio 1.1.0:文件-项目结构-标签口味-选择最小SDK版本,它高于显化。
0
I have the second solution:
我有第二个办法:
https://dl.dropboxusercontent.com/u/16403954/android-21.zip
to sdk\platforms\
change build.gradle like
改变构建。它就像
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "package.name"
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
add
添加
in Manifest with xmlns:tools="schemas.android.com/tools"
;
在清单xmlns:工具= "schemas.android.com/tools”;
Go to sdk\extras\android\m2repository\com\android\support\support-v4\21.0.0-rc1\
去android sdk \配件\ \ android m2repository \ com \ \ \ support-v4 \ 21.0.0-rc1 \支持
unpack support-v4-21.0.0-rc1.aar and edit AndroidManifest.xml like
解压缩support-v4-21.0.0-rc1。aar和编辑AndroidManifest。xml一样
from
从
to
来
P.S. You can do this with all support libraries that need.
您可以在需要的所有支持库中执行此操作。
0
The only thing that worked for me is this:
对我来说唯一有用的是:
In project.properties, I changed:
在项目。属性,我改变了:
cordova.system.library.1=com.android.support:support-v4:+ to cordova.system.library.1=com.android.support:support-v4:20.+
cordova.system.library.1 = com.android。支持:support-v4:+ cordova.system.library.1 = com.android.support:support-v4:20。+