0

什么是增加 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 并为仅用于测试的库删除用户。

4

1 回答 1

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
于 2014-09-28T06:22:47.930 回答