【问题标题】:How to build a release version of react-native Examples如何构建 react-native 示例的发布版本
【发布时间】:2016-01-06 10:07:25
【问题描述】:

现在,我可以在我的手机上安装 react-native 示例的调试版本。 请按照以下步骤操作:

./gradlew :Examples:UIExplorer:android:app:installDebug
./packager/packager.sh

但我必须启动服务器才能使应用程序正确运行。 我想将 js-bundle 文件捆绑到 apk 并在我的手机上安装发布版本。 我可以在任何地方向我的朋友展示它。 有谁能够帮助我? 提前感谢您的帮助或一些提示。

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    首先,您需要按照documentation 中的说明对您的 apk 文件进行签名并将发布构建类型添加到您的 gradle 配置中

    然后,使用 ./packager/packager.sh 或简单地 npm start 运行您的打包程序。

    下一步是将 js 包下载到 android assets 目录。因为没有 react.gradle 文件,所以需要手动完成 - source:

    curl "http://localhost:8081/Examples/UIExplorer/UIExplorerApp.android.bundle?platform=android&dev=false" -o "Examples/UIExplorer/android/app/src/main/assets/UIExplorerApp.android.bundle"
    

    最后,您可以运行installRelease gradle 任务(或assembleRelease 然后手动安装apk)。

    【讨论】:

      【解决方案2】:

      更新 pianiel 的回答:curl 命令现在是

      curl "http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.android.bundle?platform=android&dev=false" -o "Examples/UIExplorer/android/app/src/main/assets/UIExplorerApp.android.bundle"
      

      因为 UIExplorer 的项目结构发生了变化。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-04-05
        • 1970-01-01
        • 2021-06-13
        • 1970-01-01
        • 2018-10-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多