由于下载了最新的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
另外,如果你正在导入appcompat-v7库,请确保在它的末尾标记一个版本号,如下所示:
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
在只更改了support-v4版本后,我仍然收到错误:
清单合并失败:uses-sdk:minSdkVersion 15不能小于库com.android.support:support-v4:21.0.0-rc1中声明的版本L
这有点令人困惑,因为它看起来仍然是v4的问题,但实际上,限制appcompat v7版本解决了这个问题。
对于那些在Android Studio测试版中遇到这个问题的人来说,公认的答案并不能解决我的问题。导入一个从GitHub下载的项目,在我的构建中有以下内容。Gradle文件的应用程序给出一个错误的问题:
dependencies {
compile 'com.android.support:support-v4:+'
}
但是在我的外部库文件夹中,我有这个文件夹:
support-v4-21.0.0-rc1 //note the 21
我通过将依赖项更改为解决了上述问题:
dependencies {
compile 'com.android.support:support-v4:20.+' //20 used less than available strange but works
}
注意:为了正常工作,你可能还需要下载一些低于当前Android Studio中可用的api级别的库和项目。
另外,如果你正在导入appcompat-v7库,请确保在它的末尾标记一个版本号,如下所示:
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
在只更改了support-v4版本后,我仍然收到错误:
清单合并失败:uses-sdk:minSdkVersion 15不能小于库com.android.support:support-v4:21.0.0-rc1中声明的版本L
这有点令人困惑,因为它看起来仍然是v4的问题,但实际上,限制appcompat v7版本解决了这个问题。
我有一些项目,我喜欢针对L.MR1(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:+'
}