Reputation: 369
I have an android studio project with minSdkVersion set to 14 in both AndroidManifest.xml and in build.gradle
Now I want to write some automated tests so I added some more dependences in build.gradle. One of them is: androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
When I try to run the tests I get:
Error:(5, 5) uses-sdk:minSdkVersion 14 cannot be smaller than version 18 declared in library com.android.support.test.uiautomator/uiautomator-v18/2.1.1/AndroidManifest.xml
Error:Execution failed for task ':app:processDebugTestManifest'. java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 18 declared in library com.android.support.test.uiautomator/uiautomator-v18/2.1.1/AndroidManifest.xml Suggestion: use tools:overrideLibrary="android.support.test.uiautomator.v18" to force usage
I changed my manifest file to: , but this didn't help.
If I change build.gradle to minSdkVersion 18, then it works. But I don't want to change the minSdkVersion of my app just because of the test libraries.
Is there a way to configure build.gradle to use minSdkVersion 18 when I run the automated tests, but keep minSdkVersion 14 for the app?
Upvotes: 4
Views: 1012
Reputation: 369
Here is how I did it:
Below is the excerpt from my build.gradle
defaultConfig {
applicationId "..."
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
productFlavors {
appConfig {
}
testConfig {
minSdkVersion 18
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
}
}
dependencies {
...
testConfigCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
Upvotes: 2