Android 關於Bug error: resource android:attr/dialogCornerRadius not found.

簡單記錄

因爲工程targetSdkVersion升級到28以後,而且compileSdkVersion 也使用28以後就會出現上述報錯。這是因爲一些第三方庫沒有作及時的兼容。不少React Native工程第三庫都會報這個錯誤。以下所示java

<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: &quot;Roboto Mono&quot;, 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>

複製代碼

解決方法

既然知道了是因爲編譯問題致使的Bug,那麼咱們強制修改第三庫裏的targetSdkVersion和compileSdkVersion 就能夠了,解決方法以下,在主工程build.gradle文件中加入下段代碼,望對你們有幫助!node

allprojects {
    repositories {
        google()
        mavenLocal()
        ............
    }
    subprojects {
        afterEvaluate {
            project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion = 28
                        buildToolsVersion = "28.0.3"
                    }
                }
        }
    }
}
複製代碼
相關文章
相關標籤/搜索