Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'. > Dependency Error. See console for details

enter image description hereError: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

like image 640
HillHacker Avatar asked Nov 03 '16 05:11

HillHacker


3 Answers

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'
    }
like image 114
piotrek1543 Avatar answered Nov 11 '22 16:11

piotrek1543


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'

like image 30
user5588577 Avatar answered Nov 11 '22 17:11

user5588577


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'
    }
}
like image 1
Ishan Fernando Avatar answered Nov 11 '22 15:11

Ishan Fernando