React Native 构建在 android 中失败,@react-native-community/cli-platform-android /native_modules.gradle' line: 130

Yas*_*nth 10 android gradle reactjs react-native

我已将我的 ReactNative 项目从0.59升级到 0.61.2 iOS 构建良好,但在 android 中我面临@react-native-community/cli-platform-android模块中的问题。

我的settings.gradle文件

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

Run Code Online (Sandbox Code Playgroud)

我的build.gradle文件

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Run Code Online (Sandbox Code Playgroud)

构建应用程序时出现以下错误。

> Task :app:generatePackageList FAILED

FAILURE: Build failed with an exception.

* Where:
Script '/Users/yashwanth_c/Documents/projects/MobileApp/node_modules/@react-native-community/cli-platform-android
/native_modules.gradle' line: 130

* What went wrong:
Execution failed for task ':app:generatePackageList'.
> ReactNativeModules$_generatePackagesFile_closure3

* 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.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5m 21s
4 actionable tasks: 4 executed
Run Code Online (Sandbox Code Playgroud)

和往常一样,我清理了缓存并删除了 node_module 文件夹,尝试了很多次但没有运气。也用谷歌搜索了一个多星期,但仍然无法找到解决办法,任何建议表示赞赏。

rad*_*huq 12

我在 monorepo 工作。该文件存在,但它位于我的项目根目录中node_modules/@react-native-community,而不是包中node_modules

为了解决这个问题,我更新了路径

/android/settings.gradle : Line 2

apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
Run Code Online (Sandbox Code Playgroud)

/android/app/build.gradle : Line 225

apply from: file("../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Run Code Online (Sandbox Code Playgroud)


Pan*_*egi 6

我在 React Native 0.61.0 中遇到了同样的问题。我尝试了以下解决方案:-

  1. 关闭安卓工作室。
  2. 光盘安卓
  3. ./gradlew --stop (in MacOS)
  4. ./gradlew cleanBuildCache (in MacOS)

对于窗户:-

  1. gradlew --stop
  2. gradlew cleanBuildCache

检查以下链接以获取更多参考https://github.com/react-native-community/cli/issues/591

  • 在 RN 0.63.3 上有帮助,我使用的另一个最后手段修复程序是: `cd android ; rm -rf 应用程序/构建;./gradlew --停止;./gradlew 干净;./gradlew cleanBuildCache; 光盘 ../; 反应本机运行 Android` (2认同)

Ela*_*n r 5

我遇到了同样的问题,然后我尝试了下面的命令。它对我有用。这意味着,手动安装 android cli 包。

npm i @react-native-community/cli-platform-android
Run Code Online (Sandbox Code Playgroud)

如果有人知道另一种解决方案,请在此处分享。

  • 该解决方案解决了特定的构建问题。但是,像往常一样,解决一个问题就会发现下一个问题……;-\ 我使用了 `yarn add @react-native-community/cli-platform-android` 来代替。 (5认同)

MD.*_*NIM 5

我也面临同样的问题。我不知道,但由于某种原因,node_modules cli-platform-android包文件夹中没有显示。

然后我按照以下步骤来解决问题。

-> Remove `node_modules` folder
-> Remove `package-lock.json` file
-> Then install all the package again using `npm install`
-> Then `Rebuild the project in android studio`. That is how my issue was solved.
Run Code Online (Sandbox Code Playgroud)


Fai*_*taq 5

删除“node_modules”、“packagelock.json”文件夹,然后

yarn add @react-native-community/cli-platform-android@3.0.3
cd android && gradlew clean
Run Code Online (Sandbox Code Playgroud)