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

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

问题描述

由于我是本机新手,所以如果步骤中有任何问题,请通知我.

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

react-native android

react-native android

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

while running on device the following command was used

react-native run-android

react-native run-android

这给了我 projectfolder/android/app/build/outputs/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.

你们能帮助我找到如何在本机反应中构建和未签名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`

P.S.另一种方法可能是修改gradle脚本.

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

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

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