Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.
Dependency Error. See console for details.
After adding the the following dependencies in app.gradle file -
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// add this for intent mocking support
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
// add this for webview testing support
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
Console Logs -
Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug] Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (25.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details. Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.
Dependency Error. See console for details. Information:BUILD FAILED Information:Total time: 28.459 secs Information:1 error Information:1 warning Information:See complete output in console
You need to add this line to your dependencies:
androidTestCompile 'com.android.support:support-annotations:25.0.0'
to force using the latest version of library
You can also try to exclude conflict packages like I did for espresso-contrib
library
dependencies {
ext.JUNIT_VERSION = '4.12'
ext.AA_VERSION = '4.0.0'
ext.SUPPORT_VERSION = '24.1.1'
ext.ESPRESSO_VERSION = '2.2.2'
...
androidTestCompile "com.android.support:support-annotations:$SUPPORT_VERSION"
androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile "com.android.support.test.espresso:espresso-intents:$ESPRESSO_VERSION"
/**
* AccessibilityChecks
* CountingIdlingResource
* DrawerActions
* DrawerMatchers
* PickerActions (Time and Date picker)
* RecyclerViewActions
*/
androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION") {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-v7'
exclude group: 'com.android.support', module: 'design'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
I got the same probleme,when I add the following code in my app's build.gradle
within android { }
,that's ok.
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
you can get reason in this page
Execution failed for task 'app:prepareDebugAndroidTestDependencies'
This happen because of library version conflict in the debug app and test app. Add this under android{} tag
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:24.1.1'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With