【问题标题】:React native android code push installRelease build failsReact 本机 android 代码推送 installRelease 构建失败
【发布时间】:2023-03-26 13:19:01
【问题描述】:

我正在尝试将代码推送添加到我的 react 本机应用程序中,并遵循https://github.com/Microsoft/react-native-code-push 中提到的所有步骤 完成后,我的调试版本工作正常 我用:

$ ./gradlew installDebug

但发布构建失败,由以下命令给出:

$ ./gradlew installRelease

给出以下错误:

:app:generateReleaseResources
:app:mergeReleaseResources
:app:bundleReleaseJsAndAssets

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not list contents of '/Users/jayshah/Documents/testdir/ExampleApp/node_modules/.bin/_mocha'.

GitHub 微软/react-native-code-push react-native-code-push - CodePush 服务的 React Native 插件。

我使用以下命令生成包:

curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

我的 react 原生版本是 0.18, 代码推送版本为0.16

【问题讨论】:

    标签: android gradle react-native code-push


    【解决方案1】:

    原来这是将 react native 从 0.15 之前的版本升级到 0.15 之后的版本时经常遇到的问题。

    react gradle 任务 bundleReleaseJsAndAssets 似乎是罪魁祸首。

    可以使用

    禁用它
    enabled config.bundleInRelease ?: false 
    

    在 react.gradle 或注释该行(但不保证正常工作)

    inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
    

    并使用手动制作捆绑文件 react-native bundle 命令

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

    或基于 curl 的命令

    curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
    

    【讨论】:

      猜你喜欢
      • 2023-04-06
      • 1970-01-01
      • 2018-03-08
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      • 2020-08-12
      相关资源
      最近更新 更多