在没有开发服务器的设备上构建和安装未签名的 apk? [英] Build and Install unsigned apk on device without the development server?

查看:41
本文介绍了在没有开发服务器的设备上构建和安装未签名的 apk?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我是 react-native 的新手,所以如果步骤中有任何错误,请告诉我.

As I am new in react-native so if there is anything wrong in steps let me know.

我已经按照文档使用命令构建了一个 React Native android 应用

I have build a react native android app using the command as per documentation

反应原生安卓

在设备上运行时使用了以下命令

while running on device the following command was used

react-native run-android

react-native run-android

这给了我 projectfolder/android/app/build/outputs/apk 中 2 个 apk 文件的输出

现在,当我在安装后安装此 apk 时,它要求开发服务器连接以捆绑 JS.但我的要求是用户不必为开发服务器而烦恼,他只需要安装 apk 就可以了.

now when I use to install this apk after the installation it ask for an development server to connect to bundle the JS. But my requirement is that the user doesn't have to struggle with the development server just he needs to install the apk and everything is done.

已经了解了一些 stackoverflow 问题但没有帮助构建不需要开发服务器的未签名apk.

Have gone through some stackoverflow Questions but not helpful to build unsigned apk which doesn't require development server.

你们能帮我找到如何在 React Native 中构建和未签名的 apk 的方法吗?

Can you guys help me finding the way that how to build and unsigned apk in react native?

推荐答案

您需要为调试版本手动创建包.

You need to manually create the bundle for a debug build.

捆绑调试版本:

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

#React-Native 0.49.0+
react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

#React-Native 0-0.49.0
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

然后在打包后构建APK:

Then to build the APK's after bundling:

$ cd android
#Create debug build:
$ ./gradlew assembleDebug
#Create release build:
$ ./gradlew assembleRelease #Generated `apk` will be located at `android/app/build/outputs/apk`

附言另一种方法可能是修改 gradle 脚本.

P.S. Another approach might be to modify gradle scripts.

这篇关于在没有开发服务器的设备上构建和安装未签名的 apk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆