報錯內容:
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,導致所有的安卓在2022年11月4日之后都無法build殿遂,也無法啟動
詳情見下面鏈接:
https://github.com/facebook/react-native/issues/35210
解決:根據鏈接中的補丁亚情,升級到相應的版本,然后clean android之后重新啟動
比如我是:"react-native": "0.66.1",
升級到補丁版本:"react-native": "0.66.5",
然后:yarn install
然后:cd android && ./gradlew clean
然后啟動:yarn android
后面yarn install時出現提示:
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