第一次安装Android stduio出现异常:Conflict with dependency 'com.android.support:support-annotations'

新建项目出现异常:

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'    }
}

你可能感兴趣的:(学习)