问题
Following on from another question, which is resolved.
I'm following through the Start Developing for Android course in Pluralsight. We're just about to add tests. The instructions say to add add androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' to the build.gradle file (the one in the app module).
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
defaultConfig {
applicationId 'com.sqisland.android.hello'
minSdkVersion 1
targetSdkVersion 24
versionCode 1
versionName '1.0.0'
}
dependencies {
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
}
}
When I sync the build I can an error though:
Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] F:\BanksySan\Development\PluralSight\android-hello-world\app\build\intermediates\exploded-aar\com.android.support.test.espresso\espresso-core\2.2.2\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage
Should I use the suggested fix? At the moment I'm thinking that's it's more likely that I'm missing a library somewhere.
After Andy's suggestion below
I've moved the block outside, the error is:
Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] F:\BanksySan\Development\PluralSight\android-hello-world\app\build\intermediates\exploded-aar\com.android.support.test.espresso\espresso-core\2.2.2\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage
回答1:
Move the dependencies block out of android block and raise your minSdkVersion to at least 8:
android {
minSdkVersion: 8
//...
}
dependencies {
// ....
}
来源:https://stackoverflow.com/questions/41399724/cannot-find-androidtestcompile-on-android-build