react-native安卓無法啟動checkDebugAarMetadata和appcompat

報錯內(nèi)容:

Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.appcompat:appcompat:1.4.1.

原因:react-native官方BUG,導(dǎo)致所有的安卓在2022年11月4日之后都無法build,也無法啟動

詳情見下面鏈接:
https://github.com/facebook/react-native/issues/35210

解決:根據(jù)鏈接中的補(bǔ)丁,升級到相應(yīng)的版本,然后clean android之后重新啟動

比如我是:"react-native": "0.66.1",
升級到補(bǔ)丁版本:"react-native": "0.66.5",
然后:yarn install
然后:cd android && ./gradlew clean
然后啟動:yarn android

后面yarn install時出現(xiàn)提示:

  Don't worry! This is probably fine. The patch was still applied
  successfully. Here's the deets:

  Patch file created for

    react-native@0.66.1

  applied to

    react-native@0.66.5
  
  At path
  
    node_modules/react-native

  This warning is just to give you a heads-up. There is a small chance of
  breakage even though the patch was applied successfully. Make sure the package
  still behaves like you expect (you wrote tests, right?) and then run

    patch-package react-native

  to update the version in the patch file name and make this warning go away.

只要執(zhí)行命令:patch-package react-native

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容