如何在 Android 手机上运行 React Native 应用程序 [英] How to run React Native app on Android Phone

查看:54
本文介绍了如何在 Android 手机上运行 React Native 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建 React Native 应用程序.

I am building React Native app.

当我使用react-native run-android"在 Mac 上的终端中启动应用程序时,它运行良好.

It is working well when I launch the app in terminal on Mac using "react-native run-android".

但是当我拿到 apk 文件并手动将它安装到另一个安卓设备上时,它不起作用.

But when I got the apk file and installed it on another android device manually, it does not work.

看起来像这样.

推荐答案

看起来您的 APK 中的源代码正在寻找包服务器.

Looks like the source code in your APK is looking for the package server.

阅读有关如何为 react-native 构建 APK 的内容:React-Native - 生成签名 APK

Read this on how to build APKs for react-native: React-Native - Generating Signed APK

如果您的设备通过电缆连接:

If your devices is connected via cable:

  • 如果您使用的是连接到同一台机器的物理设备,请运行adb reverse tcp:8081 tcp:8081"以转发来自您设备的请求

否则,您仍然可以按照错误中的最后一点通过 Wifi 执行此操作:

Otherwise, you can still do this via Wifi by following the last point in the error:

  • 如果您的设备在同一个 Wi-Fi 网络上,请设置调试服务器主机和"将开发设置"中的设备端口"添加到您机器的 IP 地址和本地开发服务器的端口 -e.g.10.0.1.1:8081

这篇关于如何在 Android 手机上运行 React Native 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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