首页 > 解决方案 > 模拟器屏幕卡在从 10.0.0.2:8081 加载时。可能是什么问题?

问题描述

我正在尝试在 android-emulator 中运行一个简单的入门应用程序,它显示的内容如下: 在此处输入图像描述

我不确定,我哪里出错了。以下是我到达这里的步骤:

就这些。这是命令的输出react-native run-android

Scanning folders for symlinks in /home/suhail/test/react-native/HelloWorld/node_modules (10ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Task :app:installDebug 
Installing APK 'app-debug.apk' on 'Nexus_Phone(AVD) - 6.0' for app:debug
Installed on 1 device.


BUILD SUCCESSFUL in 1m 48s
28 actionable tasks: 1 executed, 27 up-to-date
Running /home/suhail/Android/Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Starting the app on emulator-5554 (/home/suhail/Android/Sdk/platform-tools/adb -s emulator-5554 shell am start -n com.helloworld/com.helloworld.MainActivity)...
Starting: Intent { cmp=com.helloworld/.MainActivity }

它不显示任何错误消息。那有什么,我失踪了吗?

标签: androidreact-nativereact-native-androidavd

解决方案


我终于能够使用@Nguyen 回答和其他一些步骤来解决问题。以下是我遵循的步骤:

  • 在模拟器上按 ctrl+m (Linux) 并打开开发者菜单。
  • 选择调试服务器和端口并将值设置为 localhost:8081
  • mkdir android/app/src/main/assets
  • 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 /主/资源
  • react-native run-android
  • 在另一个终端,我还使用启动了服务器npm start

在运行命令 4 时,我收到一条错误消息watchman-crawl-failed,可以通过参考这个 SO 帖子来解决


推荐阅读