3

I get the message: Execution failed for task 'app:prepareDebugAndroidTestDependencies' which I couldn't find what it's about.

I also tried the solution of this answer https://stackoverflow.com/a/40019612/3925663

error log:

Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (24.2.1) 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.

build.gradle:

apply plugin: 'com.android.application'

android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
    }
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.appspot.whatshouldiwearapp.wsiw"
        minSdkVersion 9
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary  'org.apache.http.legacy'

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    androidTestCompile 'com.android.support.test:runner:0.5'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    testCompile 'junit:junit:4.12'

}

What's the solution to the problem and what caused this?

Community
  • 1
  • 1
snir
  • 121
  • 1
  • 1
  • 8
  • Possible duplicate of [Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'. > Dependency Error. See console for details](https://stackoverflow.com/questions/40394736/errorexecution-failed-for-task-apppreparedebugandroidtestdependencies-de) – Shirish Herwade Mar 30 '18 at 08:55

1 Answers1

9

i solve the error by this answer: https://stackoverflow.com/a/37717407/3925663

caused by:

Conflict between the versions of the test-app and the main app of the libary: 'com.android.support:support-annotations'

soultion:

i change this

configurations.all {
  resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}

to this:

configurations.all {
  resolutionStrategy {
    force 'com.android.support:support-annotations:24.2.1'
  }
}

This fixed my issue.

Community
  • 1
  • 1
snir
  • 121
  • 1
  • 1
  • 8