首页 > 解决方案 > React Native,为什么 react-native run-android 不起作用?

问题描述

更新项目文件后,我尝试运行 react native run-android ,但是每当我运行react-native它时都会引发错误。当我创建该项目和该命令时,它运行良好,但是当我编辑和添加一些文件(如应用程序/redux、应用程序/组件、屏幕等)时,它停止工作。谁能告诉我为什么它不起作用?

error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

> Task :app:compileDebugJavaWithJavac

> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.

> Task :app:installDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 6 executed, 21 up-to-date
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

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

BUILD FAILED in 1m 11s

error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API. 

标签: javascriptandroidreact-native

解决方案


您需要创建虚拟设备或连接启用 USB 调试的物理设备 ( https://developer.android.com/studio/debug/dev-options )。

要创建一个虚拟设备,打开 android studio 并从Configure菜单中选择 AVD manager 并创建一个新的虚拟设备下载所需的包。


推荐阅读