与依赖关系“com.android.support:support-annotations”冲突。应用(23.1.0)和测试应用(23.0.1)的已解决版本不同

前端之家收集整理的这篇文章主要介绍了与依赖关系“com.android.support:support-annotations”冲突。应用(23.1.0)和测试应用(23.0.1)的已解决版本不同前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当构建我得到以下错误
  1. Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ.

这些是我的gradle依赖

  1. dependencies {
  2. compile fileTree(include: ['*.jar'],dir: 'libs')
  3. compile 'com.android.support:support-v4:23.1.0'
  4. compile 'com.android.support:appcompat-v7:23.1.0'
  5. compile 'com.android.support:design:23.1.0'
  6. compile 'com.android.support:cardview-v7:23.1.0'
  7. compile 'com.android.support:recyclerview-v7:23.1.0'
  8. compile 'com.squareup.retrofit:retrofit:1.9.0'
  9. compile 'com.squareup.okhttp:okhttp:2.4.0'
  10. compile 'com.squareup.picasso:picasso:2.5.2'
  11. compile 'com.jakewharton:butterknife:7.0.1'
  12. compile 'com.squareup:otto:1.3.8'
  13. compile 'com.snappydb:snappydb-lib:0.5.2'
  14. compile 'com.esotericsoftware.kryo:kryo:2.24.0'
  15. compile 'com.google.dagger:dagger:2.0.1'
  16. apt 'com.google.dagger:dagger-compiler:2.0.1'
  17. compile 'javax.annotation:javax.annotation-api:1.2'
  18. compile 'io.reactivex:rxandroid:1.0.1'
  19. compile 'io.reactivex:rxjava:1.0.14'
  20. compile 'com.google.android.gms:play-services-location:8.1.0'
  21. compile 'com.google.android.gms:play-services-gcm:8.1.0'
  22. compile 'org.apache.commons:commons-lang3:3.4'
  23. testCompile 'junit:junit:4.12'
  24. testCompile 'org.hamcrest:hamcrest-library:1.3'
  25. testCompile 'org.mockito:mockito-core:1.10.19'
  26. androidTestCompile 'com.android.support.test:runner:0.4'
  27. androidTestCompile 'com.android.support.test:rules:0.4'
  28. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
  29. androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
  30. androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.1'
  31. debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
  32. releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
  33. }

如何解决这个问题?

您可以在测试中强制使用注释库:
  1. androidTestCompile 'com.android.support:support-annotations:23.1.0'

这样的东西:

  1. // Force usage of support annotations in the test app,since it is internally used by the runner module.
  2. androidTestCompile 'com.android.support:support-annotations:23.1.0'
  3. androidTestCompile 'com.android.support.test:runner:0.4.1'
  4. androidTestCompile 'com.android.support.test:rules:0.4.1'
  5. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
  6. androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
  7. androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.1'

另一个解决方案是在顶层文件中使用:

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

猜你在找的设计模式相关文章