增加androidTest的minSdk

时间:2014-09-09 21:22:34

标签: android gradle assertj

增加androidTest的minSDK有什么好方法?背景是这样的:

/tmp/manifestMerge4291657485597766957.xml:0:0 Error:
    uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library com.squareup.assertj:assertj-android:1.0.0
:android:processForAmazonDebugTestManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:processForAmazonDebugTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library com.squareup.assertj:assertj-android:1.0.0

我不仅仅想增加minSDK并且仅为了仅用于测试的lib而删除用户。

1 个答案:

答案 0 :(得分:2)

这可以通过向gradle.build添加产品风格来完成:

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        packageName "org.foo"
        minSdkVersion 8
        targetSdkVersion 19
    }

    productFlavors {
        JellyBean {
            minSdkVersion 17
        }
    }
}

构建和运行JellyBean风格测试的任务是:

./gradlew assembleJellyBeanDebugTest
./gradlew connectedAndroidTestJellyBeanDebug