使用Recyclerview降低SDK版本时,清单合并失败

时间:2014-12-09 15:38:27

标签: android android-studio android-5.0-lollipop android-recyclerview

我可以收到以下错误: 错误:任务':app:processDebugManifest'执行失败。

  

清单合并失败:uses-sdk:minSdkVersion 15不能与库中声明的版本L不同... / com.android.support/recyclerview-v7/21.0.0-rc1/AndroidManifest.xml

以下是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 20
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
    compile 'com.android.support:cardview-v7:21.0.0-rc1'
    ...

}

使用

<uses-sdk
    tools:node="replace" />

不再有用了。

我看过this。建议使用gradle.build

中的代码
android.applicationVariants.all { variant ->
variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
variant.processManifest.enabled=false }

但我收到错误

Error:(21, 0) Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@dac7b2d.

无论我将代码放在gradle.build

中的哪个位置

1 个答案:

答案 0 :(得分:1)

替换:

compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
compile 'com.android.support:cardview-v7:21.0.0-rc1'

使用:

compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'

使用这些库的生产版本,而不是仅限L的预览版本。他们将回到API级别7。