For example, there is a dependency in build.gradle
:
androidTestCompile 'com.android.support:support-annotations:25.3.1'
Gradle show conflict when sync:
Conflict with dependency 'com.android.support:support-annotations' in project ':demo'. Resolved versions for app (27.0.0) and test app (25.3.1) differ
According to:
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.
So modify it:
androidTestCompile 'com.android.support:support-annotations:27.0.0'
网友评论