简体   繁体   English

如何在手机上安装 React Native 应用程序

[英]how to install react native app onto phone

(This is probably a very short and general question) (这可能是一个非常简短和笼统的问题)

I tried to install my react-native app onto my phone without using expo.我尝试在不使用 expo 的情况下将我的 react-native 应用程序安装到我的手机上。

I was able to install my react native app onto my phone via android studio, but I get an error message stating that I need to run the metro server (Which I do).我能够通过 android 工作室将我的 react 本机应用程序安装到我的手机上,但我收到一条错误消息,指出我需要运行 Metro 服务器(我这样做了)。 How do I fix this, and, would this mean that I cannot run any react native apps without a server?我该如何解决这个问题,这是否意味着我无法在没有服务器的情况下运行任何反应本机应用程序? What would I do if I want to create an offline application?如果我想创建一个离线应用程序,我会怎么做?

What is the most sensible way of getting around all of this?解决这一切的最明智的方法是什么?

In dev mode react native run an server that serves the js bundle on port 8081 by default.在开发模式下 react native 运行一个服务器,默认在端口 8081 上为 js 包提供服务。

On android studio, the bundle location is set to localhost:8081在 android studio 上,捆绑位置设置为 localhost:8081

If you want your phone to connect to the server you may have to change the bundle location to point to your pc ip adress intead of localhost.如果您希望您的手机连接到服务器,您可能需要更改捆绑位置以指向您的电脑 ip 地址而不是 localhost。 So you would have something like 192.168.1.x:8081所以你会有类似 192.168.1.x:8081

And if you want to run your app without the bundle server, you must build if for production like environement, it's like building an apk for google play store.如果你想在没有捆绑服务器的情况下运行你的应用程序,你必须为像环境这样的生产环境构建,这就像为谷歌游戏商店构建一个 apk。 You may want to check the official documentation您可能需要查看官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM