故障排除
本文档仍为 experimental,详细信息可能会随着我们的迭代而发生变化。 欢迎在此页面分享你对 工作组内部讨论 的反馈。
英This documentation is still experimental and details are subject to changes as we iterate. Feel free to share your feedback on the discussion inside the working group for this page.
而且,它还包含几个 手动步骤。 请注意,一旦新架构稳定,这将不代表最终的开发者体验。 我们正在开发工具、模板和库,以帮助你快速开始使用新架构,而无需完成整个设置。
英Moreover, it contains several manual steps. Please note that this won't be representative of the final developer experience once the New Architecture is stable. We're working on tools, templates and libraries to help you get started fast on the New Architecture, without having to go through the whole setup.
此页面包含迁移到新架构时可能遇到的常见问题的解决方案。
英This page contains resolutions to common problem you might face when migrating to the New Architecture.
CocoaPods 和节点重置
当我们推出新架构时,CocoaPods 集成将频繁更新,并且在这些更改之一之后,你的工作区可能会处于损坏状态。 你可以通过执行以下一些步骤来清除与代码生成相关的任何更改:
英The CocoaPods integration will see frequent updates as we rollout the New Architecture, and it is possible to end up with your workspace in a broken state after one of these changes. You may clean up any changes related to the codegen by performing some of these steps:
- 在 ios 目录中运行
bundle exec pod deintegrate
,然后重新运行RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
。 - 删除
node_modules
并重新运行yarn install
。
Android 构建失败并显示 OutOfMemoryException
如果你的 Android Gradle 构建失败并显示: OutOfMemoryException: Out of memory: Java heap space.
或与内存不足相关的类似错误,你可能需要增加分配给 JVM 的内存。
英If your Android Gradle builds are failing with: OutOfMemoryException: Out of memory: Java heap space.
or similar errors related to low memory, you might need to increase the memory allocated to the JVM.
你可以通过编辑 android/gradle.properties
文件夹中的 gradle.properties
文件来做到这一点:
英You can do that by editing the gradle.properties
file in your android/gradle.properties
folder:
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
确保取消注释该行并使用 -Xmx
参数设置首选内存大小。 最低要求应为 2Gb,建议使用 4Gb。
英Make sure to uncomment the line and set the preferred memory size with the -Xmx
parameter. 2Gb should be the minimum required and 4Gb is recommended.
Android NDK 和配备 M1 Apple Silicon CPU 的 Mac
我们发现 Android NDK 和 M1 CPU(here 和 here)上的 Mac 之间存在一系列不兼容性。 由于新架构依赖于 NDK,因此你在构建过程中可能会遇到问题。
英We're aware of a series of incompatibilities between the Android NDK and Macs on M1 CPUs (here and here). As the New Architectecture relies on the NDK, you might face problems during your build.
React Native 版本 0.70 和 0.71 包含对这些构建失败的修复,我们邀请你尽可能更新到这些版本。
英React Native version 0.70 and 0.71 contains fixes for those build failures, and we invite you to update to those versions whenever possible.