由于下载了最新的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
我有一些项目,我喜欢针对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:+'
}
我有一些项目,我喜欢针对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:+'
}
在构建中。gradle文件,默认是compile 'com.android. exe。所以当你构建gradle项目时,它会考虑com.android.support:support-v4:21.0.0-rc1,因为最近的L开发者预览版本。
在下面一行中进行更改,将解决该问题。
改变
compile 'com.android.support:support-v4:+'
to
compile 'com.android.support:support-v4:20.+'
类似地,当使用v7-appcompat支持库时,从
compile’com android支持:appcompat-v7: + '
to
compile 'com.android.support:appcompat-v7:20.+'.
对于那些在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级别的库和项目。