react-native run-android 被 android-studio 模拟器上的白色显示卡住了,写成“从 10.0.2.2.8081 加载"; [英] react-native run-android got stuck with a white-display on android-studio simulator written "Loading from 10.0.2.2.8081"

查看:74
本文介绍了react-native run-android 被 android-studio 模拟器上的白色显示卡住了,写成“从 10.0.2.2.8081 加载";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是react-native的新手,按照react-native官方文档安装到linux-ubuntu.我遵循了所有步骤.除了这个问题之外,一切都运行良好.react-native run-android 命令运行成功,但是卡住了白色背景,顶部有绿色条纹.模拟器顶部的绿色条写为loding from 10.0.2.2.8081"我被这个问题困住了,其他一切都运行良好,但 android 模拟器被困在它上面

I am a newbie in react-native.I followed the official documentation of react-native to install it on linux-ubuntu. I followed all the steps.Everthing is running fine except of this problem. react-native run-android command is running successfully , but got stuck with a white background with green strip on the top . The green color strip on the top of emulator is written as " loding from 10.0.2.2.8081" I am stuck on this problem ,everthing else is running fine ,but the android simulator is stuck on it

info Starting JS server...
info Building and installing the app on the device (cd android && 
./gradlew app:installDebug)...

10:57:00 V/ddms: execute: running am get-config
10:57:00 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
10:57:00 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Pixel_XL_API_28(AVD) - 9' for app:debug
10:57:00 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
10:57:00 D/Device: Uploading file onto device 'emulator-5554'
10:57:00 D/ddms: Reading file permision of /home/babita/AwesomeProject/android/app/build/outputs/apk/debug/app-debug.apk as: rw-rw-r--
10:57:00 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
10:57:01 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:57:01 V/ddms: execute: returning
10:57:01 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
10:57:01 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:57:01 V/ddms: execute: returning
Installed on 1 device.

BUILD SUCCESSFUL in 3s
26 actionable tasks: 1 executed, 25 up-to-date
info Running /home/babita/Android/Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
info Starting the app on emulator-5554 (/home/babita/Android/Sdk/platform-tools/adb -s emulator-5554 shell am start -n com.awesomeproject/com.awesomeproject.MainActivity)...
Starting: Intent { cmp=com.awesomeproject/.MainActivity }

推荐答案

和大家讨论了很久,终于知道是什么问题了.问题是您收到错误

After a long discussion with you, I have finally figured out what the problem. The problem is that you are getting the error

无法从资产 index.android.bundle 加载脚本

unable to load script from assets index.android.bundle

并且您只需消除该错误,而尚未从捆绑包中加载应用程序以显示.所以这就是为什么你每次都会出现白屏的原因.

and you simply dismiss that error while nothing has been loading for the app from the bundle to display. So that is why you are getting a white screen every time.

在终端中执行这些步骤(因为您使用的是 Linux).Windows 用户按照 CMD 中的这些步骤

Follow these steps in Terminal (since you are using Linux). Windows users follow these steps in CMD

1) 在终端(或 CMD)中转到您的项目根目录

1) Go to your project root directory in Terminal(or CMD)

2) 运行这个命令 mkdir android\app\src\main\assets

3) 在这个命令之后运行这个命令 react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res4) 然后运行 ​​react-native run-android 命令

3) After this command run this command react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res 4) then run react-native run-android command

可选步骤

在第 3 步之后,您也可以按照以下步骤操作:

After step 3 you can follow these steps too:

3.1) cd android

3.2) gradlew clean

3.3) cd..

3.4) react-native run-android

这篇关于react-native run-android 被 android-studio 模拟器上的白色显示卡住了,写成“从 10.0.2.2.8081 加载";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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