解决方法
Resolving conflicts between main and test APK
When instrumentation tests are run, both the main APK and test APK share the same classpath. Gradle build will fail if the main APK and the test APK use the same library (e.g. Guava) but in different versions. If gradle didn’t catch that, your app could behave differently during tests and during normal run (including crashing in one of the cases).
To make the build succeed, just make sure both APKs use the same version. If the error is about an indirect dependency (a library you didn’t mention in your build.gradle), just add a dependency for the newer version to the configuration (“compile” or “androidTestCompile”) that needs it. You can also use Gradle’s resolution strategy mechanism. You can inspect the dependency tree by running ./gradlew :app:dependencies and ./gradlew :app:androidDependencies.
本文介绍了解决主APK与测试APK使用相同库的不同版本导致的构建失败问题。通过确保两个APK使用相同版本的库,或者使用Gradle的依赖解析策略来避免构建失败。
963

被折叠的 条评论
为什么被折叠?



