React Native,Android 构建由于缺少 CMakeLists.txt 而失败

Zep*_*hyr 3 android build gradle android-studio react-native

我正在尝试为 Android 构建我的 React Native 项目,但出现此错误。

FAILURE: Build completed with 2 failures. 

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:configureCMakeDebug[arm64-v8a]'.
> [CXX1409] [project folder]/android/app/.cxx/Debug/l1z3g258/arm64-v8a/android_gradle_build.json debug|arm64-v8a : expected buildFiles file '[project folder]/node_modules/react-native-screens/android/src/main/jni/CMakeLists.txt' to exist

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

Run Code Online (Sandbox Code Playgroud)

我在 Android Studio -> Build 中也遇到相同的 CMakeLists.txt 缺失错误。

错误中的库react-native-screens曾经安装过,但我不再使用它。它现在不是我的 package.json 文件的一部分。我现在在项目中可以找到的对此文件的唯一引用是在[project fodler]/android/app/.cxx/debug&[project fodler]/android/app/wef/debug文件夹中。我不确定如何清理此处的引用以不包含项目中不再安装的库。

当我./gradlew clean在 android 文件夹中运行时,我再次遇到同样的问题。

小智 9

只需删除 android/app/.cxx 文件夹并尝试重建