javascript - React-Native assembleRelease 任务 ':app:bundleReleaseJsAndAssets' 失败

标签 javascript android react-native gradle

当我运行 ./gradlew assembleRelease 构建失败并出现此错误时:

Error:Execution failed for task ':app:bundleReleaseJsAndAssets. 
> A problem occurred starting process 'command 'node'

我在互联网上搜索并找到了一些关于它的主题,但我无法解决我的问题。

React-Native 版本:0.54.0

编辑:
现在我从终端而不是 Android Studio 运行 ./gradlew assembleRelease --info,我得到了不同的错误。
这是结果:

> Task :app:processReleaseResources
Putting task artifact state for task ':app:processReleaseResources' into context took 0.007 secs.
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
Executing task ':app:processReleaseResources' (up-to-date check took 0.035 secs) due to:
  Task has failed previously.
All input files are considered out-of-date for incremental task ':app:processReleaseResources'.
Unable do incremental execution: full task run
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
Aapt2QueuedResourceProcessor is using **/Android/sdk/build-tools/26.0.2/aapt2
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
*
*
*
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt


似乎 gradle 在所有模块中寻找 libs 文件夹,但节点模块中没有 libs 文件夹。是的,但我不知道为什么 gradle 正在寻找 libs 文件夹。

最佳答案

首先:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

最终构建:

./gradlew assembleRelease -x bundleReleaseJsAndAssets

关于javascript - React-Native assembleRelease 任务 ':app:bundleReleaseJsAndAssets' 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49513047/

相关文章:

javascript - 需要帮助将 HTML 代码渲染到类型为 ="html"的 px-data-column

javascript - 对 js proto 和分配新属性感到困惑

java - 在 Android 中使用 `Objects.equals()`

javascript - 如何在 native react 中限制文本字段的退格事件

react-native - 使用 React-Router-Native 从 React Native 中的 Axios 拦截器(组件外部)重定向到 View 组件

javascript - 将对象设置为在 ngoptions 中选中

javascript - 未捕获的类型错误 : Cannot call method 'get' of null

android - 如何初始化依赖于 View 属性的东西

android - 如何在 jetpack compose 中使用 retrofit API 创建 ListView / GridView /回收器 View

android - 如何在 native 输出中获取组件代码