[关闭]
@martin0207 2018-02-02T02:22:31.000000Z 字数 3292 阅读 1064

Error:Execution failed for task ':app:prepare Debug Android Test Dependencies'.

Dependency Error. See console for details.

错误记录


前言

今天遇到个奇葩的问题,刚刚打包还好好的,突然就爆出:

  1. Error:Execution failed for task ':app:prepare Debug Android Test Dependencies'.
  2. > Dependency Error. See console for details.

借助我英语二级的水平,颤颤巍巍打开有道翻译了下:

错误:任务执行失败:app:准备调试Android测试依赖项。
依赖性错误。有关详细信息,请参阅控制台。

相信各位看得很明白,所以,依照惯例,我还是去百度了下。

参考方法

一、 11个支持

I got the same probleme,when I add the following code in my app's build.gradle within android { },that's ok.
我也遇到了同样的问题,在我把下面的代码放到app的build.gradle的android方法下的时候,这个问题就解决了。(自译,谅)

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

虽然我试了下,没啥用,但11个支持可能有用,但我这边问题比较奇葩吧。各位可以试一下。

二、 8个支持

You need to add this line to your dependencies:
您需要将这一行添加到您的依赖项中。(有道)

  1. 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
使用最新版本的库。
您也可以尝试排除冲突包,就像我为espresso- b库所做的那样。(有道)

  1. dependencies {
  2. ext.JUNIT_VERSION = '4.12'
  3. ext.AA_VERSION = '4.0.0'
  4. ext.SUPPORT_VERSION = '24.1.1'
  5. ext.ESPRESSO_VERSION = '2.2.2'
  6. androidTestCompile "com.android.support:support-annotations:$SUPPORT_VERSION"
  7. androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
  8. androidTestCompile 'com.android.support.test:runner:0.5'
  9. androidTestCompile "com.android.support.test.espresso:espresso-intents:$ESPRESSO_VERSION"
  10. /**
  11. * AccessibilityChecks
  12. * CountingIdlingResource
  13. * DrawerActions
  14. * DrawerMatchers
  15. * PickerActions (Time and Date picker)
  16. * RecyclerViewActions
  17. */
  18. androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION") {
  19. exclude group: 'com.android.support', module: 'appcompat'
  20. exclude group: 'com.android.support', module: 'support-v4'
  21. exclude group: 'com.android.support', module: 'support-v7'
  22. exclude group: 'com.android.support', module: 'design'
  23. exclude module: 'support-annotations'
  24. exclude module: 'recyclerview-v7'
  25. }

这个答案就很有质量了,虽然我试了下也没用。

三、 1个赞

This happen because of library version conflict in the debug app and test app. Add this under android{} tag
这问题是因为引入库的版本在调试和测试App两个环境中存在冲突,在app的(build.gradle)下面的androi{}标签里面添加这个(自译,谅)

  1. configurations.all {
  2. resolutionStrategy {
  3. force 'com.android.support:support-annotations:24.1.1'
  4. }
  5. }

三个解决方法都没有解决我的问题,这里记录下来,可能会解决各位的问题。

自力更生

习惯使然,让我遇到问题就想要百度求支援,但问题已经告诉我们了依赖性错误。有关详细信息,请参阅控制台。所以,我还是摸索着看了看按钮:
左边的按钮

我上看下看左看右看,也就只有右列的第四个像是控制台输出,点开还真是:

  1. :app:generateDebugSources
  2. :app:preDebugAndroidTestBuild UP-TO-DATE
  3. :app:prepareComAndroidSupportMultidex101Library
  4. :app:prepareComAndroidSupportMultidexInstrumentation101Library
  5. :app:prepareDebugAndroidTestDependencies
  6. Conflict with dependency 'com.android.support:multidex' in project ':app'. Resolved versions for app (1.0.2) and test app (1.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
  7. FAILED
  8. FAILURE: Build failed with an exception.
  9. * What went wrong:
  10. Execution failed for task ':app:prepareDebugAndroidTestDependencies'.
  11. > Dependency Error. See console for details.
  12. * Try:
  13. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  14. * Get more help at https://help.gradle.org
  15. BUILD FAILED in 17s

毕竟也是英语二级的人,看了半天还是看到了问题所在

  1. Conflict with dependency 'com.android.support:multidex' in project ':app'. Resolved versions for app (1.0.2) and test app (1.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

然后去build.gradle里面把版本号改成 1.0.1,重新编译就OK了。

总结

还是要靠自己,出了问题先自己琢磨怎么解决,实在不行再去求助,这样更能增强抵抗力,遇到问题才能不慌。————来自求助一天没解决,自己看了几分钟解决的人

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注