编译依赖冲突(一)
错误信息:
Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details。
看错误信息说的是app依赖的包的版本和test app的依赖包版本不一致。
首先我看了app module的build.gradle和项目的build.gradle,没有找着有27.1.1的依赖。
看上面提示的https://d.android.com/r/tools/test-apk-dependency-conflicts.html参考,说有传递依赖。通过查看build的依赖树查看详细依赖信息,但信息比较多没有找到。
我比较了之前的项目,发现测试依赖的版本升高了,就改了回来,重新编译一下就可以了。
原先的依赖信息:
implementation 'com.android.support:appcompat-v7:26.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
修改后的依赖版本信息:
implementation 'com.android.support:appcompat-v7:26.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'