簡單記錄
由于工程targetSdkVersion升級到28之后,并且compileSdkVersion 也使用28之后就會出現(xiàn)上述報錯迄损。這是由于一些第三方庫沒有做及時的兼容。很多React Native工程第三庫都會報這個錯誤戒悠。如下所示
<pre class="console-output" style="box-sizing: border-box; white-space: pre-wrap; word-wrap: break-word; margin: 0px; position: relative; font-size: 14px; background: rgb(38, 50, 56); color: rgb(233, 237, 237); cursor: text; font-family: "Roboto Mono", monospace !important; padding: 10px 20px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':lottie-react-native:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/lottie-react-native/src/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/lottie-react-native/src/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/lottie-react-native/src/android/build/intermediates/res/merged/release/values/values.xml:2602: error: resource android:attr/fontVariationSettings not found.
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/lottie-react-native/src/android/build/intermediates/res/merged/release/values/values.xml:2603: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-fs:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/react-native-fs/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/react-native-fs/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/react-native-fs/android/build/intermediates/res/merged/release/values/values.xml:2714: error: resource android:attr/fontVariationSettings not found.
/Users/jinwenwu/.jenkins/workspace/_feature_INS_APP_DV_2019.11-ULZZDDRITLP453WEMM3EK6BSLW3Q3OCKQGKLLPOKJBCMRR5F2YLA/node_modules/react-native-fs/android/build/intermediates/res/merged/release/values/values.xml:2715: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
* Get more help at [https://help.gradle.org](https://help.gradle.org/)</pre>
解決方法
既然知道了是由于編譯問題導(dǎo)致的Bug脚仔,那么我們強(qiáng)制修改第三庫里的targetSdkVersion和compileSdkVersion 就可以了纵寝,解決方法如下,在主工程build.gradle文件中加入下段代碼赖临,望對大家有幫助胞锰!
allprojects {
repositories {
google()
mavenLocal()
............
}
subprojects {
afterEvaluate {
project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
}
}
}
}
}