在项目中手动修改targetSdkVersion之后重新编译Module发现错误:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (27.0.2) and test app (27.0.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
这个原因是因为修改了targetSdkVersion之后所依赖的,意思就是说测试版本用的库和编译版本不同,
'com.android.support:appcompat-v7:27.0.2'
v7包和测试类使用的版本不相同,
Resolved versions for app (27.0.2) and test app (27.0.1) differ.
一开始是觉得手动修改依赖测试包版本为25.3.1即可,实则不然。
下面是我本地build.gradle中原来的写法:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:j