【问题标题】:React Native run-android Only works on the first buildReact Native run-android 仅适用于第一次构建
【发布时间】:2020-07-20 20:21:40
【问题描述】:

第一次运行我的 react-native 应用程序时,模拟器可以运行(使用 Android Studio Galaxy Nexus)。但是,当我关闭模拟器并重试时,出现以下错误:

PS C:\Users\4chea\pexhouseV2> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1197 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

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

> Task :app:installDebug FAILED
Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE.

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.2/userguide/command_line_interface.html#sec:command_line_warnings
160 actionable tasks: 2 executed, 158 up-to-date

FAILURE: Build failed with an exception.

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

* 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 24s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

发生这种情况时我的模拟器处于打开状态并显示“无法连接到 Metro 服务器”

【问题讨论】:

    标签: android react-native android-studio


    【解决方案1】:

    这里告诉你问题。

    info Launching emulator...
    error Failed to launch emulator. Reason: Emulator exited before boot..
    warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
    

    您的模拟器有问题。尝试重新启动系统。如果这不起作用,请尝试制作一个新的模拟器,看看那个是否更好。另外,我会关闭你的模拟器上的快速启动功能——它可能会在你关闭它时询问你是否要保存它的内存状态以加快启动时间。过去我也遇到过类似的问题。

    如果这有什么改变,请告诉我。祝你好运。

    【讨论】:

    • 感谢您的评论。当我第一次制作新设备时,模拟器可以完美运行。当我关闭设备并运行相同的命令时,我开始收到此错误。所以模拟器只能在第一次尝试时工作。
    • 你尝试了我的建议后发生了什么?一样?您是否一遍又一遍地制作相同的模拟器 - 意味着相同的设置/设置?
    猜你喜欢
    • 2020-12-29
    • 1970-01-01
    • 1970-01-01
    • 2019-03-15
    • 2017-12-26
    • 2021-05-13
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    相关资源
    最近更新 更多