场景
Android Studio升级到3.2.1后,不知道是谁改了哪个module的依赖库版本号,build时出现以下错误
Android resource linking failed Output: /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/incremental/mergeDefaultFlavorBetaResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found. /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/incremental/mergeDefaultFlavorBetaResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found. /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/incremental/mergeDefaultFlavorBetaResources/merged.dir/values/values.xml:1735: error: resource android:attr/fontVariationSettings not found. /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/incremental/mergeDefaultFlavorBetaResources/merged.dir/values/values.xml:1736: error: resource android:attr/ttcIndex not found. error: failed linking references. Command: /Users/dujuncan/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/5f450e77e31e0af9b1b1ca1d2542b966/aapt2-3.2.1-4818971-osx/aapt2 link -I\ /Users/dujuncan/Library/Android/sdk/platforms/android-27/android.jar\ --manifest\ /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/merged_manifests/defaultFlavorBeta/processDefaultFlavorBetaManifest/merged/AndroidManifest.xml\ -o\ /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/processed_res/defaultFlavorBeta/processDefaultFlavorBetaResources/out/resources-defaultFlavorBeta.ap_\ -R\ @/Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/incremental/processDefaultFlavorBetaResources/resources-list-for-resources-defaultFlavorBeta.ap_.txt\ --auto-add-overlay\ --java\ /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/generated/not_namespaced_r_class_sources/defaultFlavorBeta/processDefaultFlavorBetaResources/r\ --proguard-main-dex\ /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/legacy_multidex_aapt_derived_proguard_rules/defaultFlavorBeta/processDefaultFlavorBetaResources/manifest_keep.txt\ --custom-package\ com.baijia.live\ -0\ apk\ --output-text-symbols\ /Users/dujuncan/AndroidStudioProjects/bjsdk/live-app-android/app/build/intermediates/symbols/defaultFlavor/beta/R.txt\ --no-version-vectors Daemon: AAPT2 aapt2-3.2.1-4818971-osx Daemon #0
解决办法
根据第二行Output的提示,是在合并value资源文件出错的,values-28中没有找到一些android:attr属性。
查看项目其它module时发现,其他module的build.gradle中compileSdkVersion存在版本不一致的情况,有的是27,有些是28.
所以最简单的办法就是让App运行时统一指定为28。
打开项目主工程(通常是app module)的build.gradle
将compileSdkVersion指定为28
android { //编译版本号 compileSdkVersion 28 ..................... }
或者用鼠标选中主工程,右键-Open Module settings,修改Compile Sdk Version.
[ ]
sync后,重新build就不会报错了.