【问题标题】:Execution failed for task ':app:prepareDebugAndroidTestDependencies' Dependency Error任务':app:prepareDebugAndroidTestDependencies'依赖错误的执行失败
【发布时间】:2016-10-17 08:05:41
【问题描述】:

我收到消息:任务“app:prepareDebugAndroidTestDependencies”执行失败,我找不到它的内容。

我也试过这个答案https://stackoverflow.com/a/40019612/3925663的解决方案

错误日志:

警告:与依赖项“com.android.support:support-annotations”冲突。应用程序 (24.2.1) 和测试应用程序 (23.1.1) 的已解决版本不同。详情请见http://g.co/androidstudio/app-test-app-conflict

错误:任务执行失败 ':app:prepareDebugAndroidTestDependencies'。 依赖错误。详情见控制台。

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'

}

解决问题的方法是什么?是什么原因造成的?

【问题讨论】:

标签: android build.gradle


【解决方案1】:

我通过这个答案解决了错误: https://stackoverflow.com/a/37717407/3925663

原因:

test-app 版本与库主app 版本冲突:'com.android.support:support-annotations'

灵魂:

我改了

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

到这里:

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

这解决了我的问题。

【讨论】:

    猜你喜欢
    • 2017-03-16
    • 2016-04-22
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 2018-06-06
    • 2016-02-16
    相关资源
    最近更新 更多