错误:任务':app:prepareDebugAndroidTestDependencies'的执行失败.>依赖性错误.请参阅控制台了解详情

Hil*_*ker 11 android gradle build.gradle android-gradle-plugin android-espresso

在此输入图像描述错误:任务':app:prepareDebugAndroidTestDependencies'的执行失败.

依赖性错误.请参阅控制台了解详情

在app.gradle文件中添加以下依赖项后 -

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'
Run Code Online (Sandbox Code Playgroud)

控制台日志 -

信息:Gradle任务[:app:clean,:app:generateDebugSources,:app:mockableAndroidJar,:app:prepareDebugUnitTestDependencies,:app:generateDebugAndroidTestSources,:app:assembleDebug]警告:与依赖项冲突'com.android.support:support-annotations ".app(25.0.0)和测试app(23.1.1)的已解决版本有所不同.有关详细信息,请参阅http://g.co/androidstudio/app-test-app-conflict.错误:任务':app:prepareDebugAndroidTestDependencies'的执行失败.

依赖性错误.请参阅控制台了解详情 信息:BUILD FAILED信息:总时间:28.459秒信息:1错误信息:1警告信息:在控制台中查看完整输出

小智 11

我得到了相同的probleme,当我在我的应用程序的添加以下代码build.gradleandroid { },这是确定. configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1' } 你可以在这个页面得到理由
任务'app:prepareDebugAndroidTestDependencies'的执行失败


pio*_*543 9

您需要将此行添加到依赖项:

androidTestCompile 'com.android.support:support-annotations:25.0.0' 
Run Code Online (Sandbox Code Playgroud)

强制使用最新版本的库

您也可以尝试排除冲突包,就像我为espresso-contrib库做的那样

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'
    }
Run Code Online (Sandbox Code Playgroud)