常见构建失败的解决方案

Android 更新 react-native-reanimated 导致构建失败

原因是 react-native-reanimated 安装了多个版本,导致了冲突,需要删除 node_modules,再重新安装依赖。

Android 构建 react-native-flipper 失败

错误信息如下:

1FAILURE: Build failed with an exception.
2
3* What went wrong:
4A problem occurred configuring project ':react-native-flipper'.
5> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
6   > Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
7
8     If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
9
10* Try:
11> Run with --stacktrace option to get the stack trace.
12> Run with --info or --debug option to get more log output.
13> Run with --scan to get full insights.
14
15* Get more help at https://help.gradle.org
暂时解决方案

目前没有弄清该错误的产生原因,只能通过固定版本号解决。如有更好的解决方案,欢迎提 PR。

  • @react-native/gradle-plugin 降级至 0.72.11
  • react-native-flipper 降级至 0.163.0