反应原生的Andr​​oid无法加载JS捆绑加载、反应、oid、Andr

2023-09-12 22:44:38 作者:樱雨墨落﹏

我想在我的Nexus5(安卓5.1.1)。

I'm trying to run AwesomeProject on my Nexus5 (android 5.1.1).

我能够生成项目,并在设备上安装它。但是,当我运行它,我得到了一个红屏说

I'm able to build the project and install it on the device. But when I run it, I got a red screen saying

无法下载JS包。你忘了启动开发服务器或连接设备?

Unable to download JS bundle. Did you forget to start the development server or connect your device?

在反应机iOS,我可以选择jsbundle离线加载。我怎样才能做同样的事情为Android? (或者至少,在那里我可以配置服务器地址?)

In react native iOS, I can choose to load jsbundle offline. How can I do the same thing for Android? (Or at least, where can I configure the server address?)

反应母语启动>的/ dev / null的2>&功放; 1安培; 在亚行反向TCP:8081 TCP:8081

请看看dsissitka的回答更多的细节。

please take a look at dsissitka's answer for more details.

创建在安卓/ APP / src目录的资产目录/主 卷曲的http://本地主机:8081 / index.android.bundle平台=机器人-o安卓/ APP / src目录/主/资产/ index.android.bundle create an assets folder under android/app/src/main curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

请看看kzzzf的回答更多的细节。

please take a look at kzzzf's answer for more details.

推荐答案

要捆绑的JS文件到您的apk,同时让您的服务器上运行(反应母语启动)下载包为您的应用程序的资产目录:

To bundle JS file into your apk while having your server running (react-native start) download bundle into assets directory of your app:

curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

使用下一个版本(0.12),我们将修复反应-本地捆绑命令将如预期的Andr​​oid项目的工作。

With the next release (0.12) we'll fix react-native bundle command to work with android projects as expected.

 
精彩推荐
图片推荐