模拟器屏幕在10.0.0.2:8081加载时卡住。可能是什么问题?

时间:2018-05-19 09:21:48

标签: android react-native react-native-android avd

我正在尝试在android-emulator中运行一个简单的入门应用程序,它显示的是以下内容: enter image description here

我不确定,我哪里错了。以下是我要遵循的步骤:

  • react-native init HelloWorld
  • 如上图所示设置AVD
  • react-native run-android

就是这样。以下是命令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 }

,不显示任何错误消息。那还有什么,我想念?

2 个答案:

答案 0 :(得分:2)

我终于能够使用@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 /应用程序/ SRC /主/ RES
  • react-native run-android
  • 在另一个终端,我还使用npm start
  • 启动了服务器

在运行命令4时,我收到错误watchman-crawl-failed,可以参考this SO post

来解决

答案 1 :(得分:1)

echo 256 | sudo tee -a /proc/sys/fs/inotify/max_user_instances
echo 32768 | sudo tee -a /proc/sys/fs/inotify/max_queued_events
echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
pkill node