2016-11-03 7 views
9

enter image description here Ошибка: выполнение выполнено для задачи ': app: prepareDebugAndroidTestDependencies'.Ошибка: выполнение выполнено для задачи ': app: prepareDebugAndroidTestDependencies'. > Ошибка зависимостей. См. Консоль для получения более подробной информации.

Dependency Error. See console for details.

После добавления следующих зависимостей в 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' 

Консоли Журналы -

Контактная информация: Gradle задачи [: приложение: чистый,: приложение: generateDebugSources,: приложение : mockableAndroidJar,: app: prepareDebugUnitTestDependencies,: app: generateDebugAndroidTestSources,: app: assembleDebug] Предупреждение: конфликт с зависимостью «com.android.support:support-annotations». Разрешенные версии для приложения (25.0.0) и тестового приложения (23.1.1) различаются. См. http://g.co/androidstudio/app-test-app-conflict. Ошибка: выполнение выполнено для задачи ': 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

ответ

11

я получил тот же problème, когда я добавить следующий код в моем приложении build.gradle в android { }, это нормально. configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1' } вы можете получить причину этой страницы
Execution failed for task 'app:prepareDebugAndroidTestDependencies'

+1

Спасибо! Имела та же проблема, и это разрешило это – enyciaa

8

Вы должны добавить эту строку в ваши зависимости:

androidTestCompile 'com.android.support:support-annotations:25.0.0' 

, чтобы заставить использовать последнюю версию библиотеки

Вы также можете попробовать исключить пакеты конфликтов, как я сделал для 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' 
    } 
1

Это происходит из-за конфликта версий библиотеки в приложении отладки и тестовом приложении. Добавьте это под android {} tag

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