报错内容:
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.
只要执行命令:patch-package react-native
网友评论