我试图从依赖项中删除一个模块:accessibility-test-framework
org.robolectric:robolectric:3.2.2使用
com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.1
com.android.support.test.espresso:espresso-contrib:2.2.2使用
com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.0
我的gradle文件如下所示:
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
testCompile ("org.robolectric:robolectric:3.2.2") {
exclude module: 'accessibility-test-framework'
}
我可以看到错误:
Warning:Conflict with dependency 'com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework'. Resolved versions for app (2.0) and test app (2.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
当我进入应用程序的工作目录并执行
时./gradlew -q app:dependencies
请参阅最后一行:
_mockDebugUnitTestCompile - ## Internal use, do not manually configure ##
+--- com.android.support:support-annotations:25.1.1
+--- com.android.support:design:25.1.1
| +--- com.android.support:support-v4:25.1.1
| | +--- com.android.support:support-compat:25.1.1
| | | \--- com.android.support:support-annotations:25.1.1
| | +--- com.android.support:support-media-compat:25.1.1
| | | +--- com.android.support:support-annotations:25.1.1
| | | \--- com.android.support:support-compat:25.1.1 (*)
| | +--- com.android.support:support-core-utils:25.1.1
| | | +--- com.android.support:support-annotations:25.1.1
| | | \--- com.android.support:support-compat:25.1.1 (*)
| | +--- com.android.support:support-core-ui:25.1.1
| | | +--- com.android.support:support-annotations:25.1.1
| | | \--- com.android.support:support-compat:25.1.1 (*)
| | \--- com.android.support:support-fragment:25.1.1
| | +--- com.android.support:support-compat:25.1.1 (*)
| | +--- com.android.support:support-media-compat:25.1.1 (*)
| | +--- com.android.support:support-core-ui:25.1.1 (*)
| | \--- com.android.support:support-core-utils:25.1.1 (*)
| +--- com.android.support:appcompat-v7:25.1.1
| | +--- com.android.support:support-annotations:25.1.1
| | +--- com.android.support:support-v4:25.1.1 (*)
| | +--- com.android.support:support-vector-drawable:25.1.1
| | | +--- com.android.support:support-annotations:25.1.1
| | | \--- com.android.support:support-compat:25.1.1 (*)
| | \--- com.android.support:animated-vector-drawable:25.1.1
| | \--- com.android.support:support-vector-drawable:25.1.1 (*)
| +--- com.android.support:recyclerview-v7:25.1.1
| | +--- com.android.support:support-annotations:25.1.1
| | +--- com.android.support:support-compat:25.1.1 (*)
| | \--- com.android.support:support-core-ui:25.1.1 (*)
| \--- com.android.support:transition:25.1.1
| +--- com.android.support:support-annotations:25.1.1
| \--- com.android.support:support-v4:25.1.1 (*)
+--- org.mockito:mockito-core:2.0.111-beta
| +--- net.bytebuddy:byte-buddy:1.4.17
| \--- org.objenesis:objenesis:2.4
+--- org.powermock:powermock-api-mockito:1.6.1
| +--- org.mockito:mockito-all:1.10.8
| \--- org.powermock:powermock-api-support:1.6.1
| +--- org.powermock:powermock-core:1.6.1
| | +--- org.powermock:powermock-reflect:1.6.1
| | | \--- org.objenesis:objenesis:2.1 -> 2.4
| | \--- org.javassist:javassist:3.18.2-GA
| \--- org.powermock:powermock-reflect:1.6.1 (*)
+--- org.powermock:powermock-module-junit4-rule-agent:1.6.1
| +--- org.powermock:powermock-module-javaagent:1.6.1
| | \--- org.powermock:powermock-core:1.6.1 (*)
| \--- org.powermock:powermock-core:1.6.1 (*)
+--- org.powermock:powermock-module-junit4-rule:1.6.1
| +--- org.powermock:powermock-classloading-base:1.6.1
| | +--- org.powermock:powermock-api-support:1.6.1 (*)
| | \--- org.powermock:powermock-reflect:1.6.1 (*)
| \--- org.powermock:powermock-core:1.6.1 (*)
+--- org.powermock:powermock-module-junit4:1.6.1
| +--- junit:junit:4.12
| | \--- org.hamcrest:hamcrest-core:1.3
| \--- org.powermock:powermock-module-junit4-common:1.6.1
| +--- junit:junit:4.4 -> 4.12 (*)
| +--- org.powermock:powermock-core:1.6.1 (*)
| \--- org.powermock:powermock-reflect:1.6.1 (*)
+--- org.robolectric:robolectric:3.2.2
| +--- org.robolectric:robolectric-annotations:3.2.2
| +--- org.robolectric:robolectric-resources:3.2.2
| | +--- org.robolectric:robolectric-utils:3.2.2
| | | +--- org.ow2.asm:asm:5.0.1
| | | +--- org.ow2.asm:asm-commons:5.0.1
| | | | \--- org.ow2.asm:asm-tree:5.0.1
| | | | \--- org.ow2.asm:asm:5.0.1
| | | +--- org.robolectric:robolectric-annotations:3.2.2
| | | \--- com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.1
有什么想法吗?
答案 0 :(得分:1)
您在应用和测试中使用的是不同版本。
您可以使用以下方式强制应用中的库:
compile 'com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.1.0'
或者只能在测试中使用espresso框架来避免这个问题:
androidTestcompile 'com.android.support.test.espresso:espresso-core:2.2.2'