新建项目出现异常:
Error: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.
意思是说关于库com.android.support:support-annotations测试版本用的库和最终用的库版本号不一致
解决方案:在APP/build.gradle文件的dependencies中添加force强制指定库的版本号,使测试版本和运行版本保持一致。把下面一项添加到dependencies里面就可以了。
dependencies{ configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:27.1.1' }}
解决依赖冲突
本文介绍了解决Android项目中因com.android.support:support-annotations版本不一致导致的构建错误的方法。通过在build.gradle文件中使用force策略统一测试和运行时依赖版本。
503

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



