运行 个 React-Native 项目的错误

Errors to run a React-Native project

我开始学习 React Native,我正在使用 Linux(Distro Fedora 29),Java 已经在工作并且 运行ning,Android Studio 已经安装和配置(遵循 android studio 文档),我的环境变量完全像:

export ANDROID_HOME=/home/ghost/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

当我 运行 我的项目 "react-native run-android" 我得到以下错误:

[ghost@localhost mobile]$ react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
> Task :app:installDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
26 actionable tasks: 1 executed, 25 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

搜索我找到了一些提示,然后我尝试重新启动 adb,例如:

adb kill-server && adb start-server

即使我那样做,运行宁adb devices什么也没有给我

[ghost@localhost mobile]$ adb devices
List of devices attached

然后我尝试 运行 在 android 工作室之前(第三张图片 url),然后它 return 我的日志:

16:56   Gradle sync started
16:56   Project setup started
16:56   Gradle sync finished in 3 s 620 ms (from cached state)
**16:56 Emulator: statvfs('/home/ghost/.android/avd/Pixel_2_API_28.avd/snapshots/default_boot/ram.img') failed: No such file or directory
16:56   Emulator: ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy
16:56   Emulator: qemu-system-x86_64: failed to initialize KVM: Device or resource busy
16:56   Emulator: Process finished with exit code 0**

**可以包含有用信息的图像

SDK 管理员:

我安装的SDK平台

我安装的SDK工具

AVD 管理器:

设备

这四天我一直在努力解决这个问题,阅读文档本身,在论坛中搜索,重做设置。但到目前为止我还做不到。提前致谢

cd android && ./gradlew clean

如果这个命令不起作用,

您可以检查 android/gradlew

的权限

他们应该是 755 而不是 644

运行 chmod 755 android/gradlew 在您的应用程序根文件夹中 然后 运行 react-native run-android

它应该会再次工作。

refer link

使用 USB 将您的 phone 连接到计算机并启用 android 调试。

出了什么问题: 任务“:app:installDebug”执行失败。

com.android.builder.testing.api.DeviceException: No connected devices!

(您的 phone 未正确连接到您的电脑。请在您的 android 设备上启用 MTP 模式。

此命令
[ghost@localhost mobile]$ adb devices
连接的设备列表

如果您的设备连接正确,应该输出类似这样的内容

adb 设备
连接的设备列表
192.168.1.75:5555 设备

感谢大家的回答,对我帮助很大!发生的问题是因为我在尝试启动 android 模拟器的同时 运行ning 无业游民,我发现在 运行ning "vagrant halt" 并尝试 运行 android 再次,在 运行ning 模拟器成为可能之后 运行 react-native 项目