【问题标题】:React Native not detecting Android emulatorReact Native 未检测到 Android 模拟器
【发布时间】:2020-05-20 10:54:00
【问题描述】:

当我做 react-native run-android 我得到这个错误:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 6 workers...
info Starting JS server...
/bin/sh: 1: adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

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.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in project ':app'.

* Try:
Run gradlew tasks to get a list of available tasks. 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 4s

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 app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in project ':app'.

* Try:
Run gradlew tasks to get a list of available tasks. 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

我不明白,在我运行我的 React Native 应用程序之前,我先打开 Android 模拟器。我还注意到我的 android studio 在欢迎页面上没有“配置”,所以如果我想访问 sdk 管理器和 avd 管理器,我必须启动一个项目。

【问题讨论】:

  • 我遇到了同样的问题,使用 React native .62 尝试运行以下react-native run-android --variant PreDebug
  • 我得到同样的错误
  • 我认为您需要检查您的项目 Gradle,从 android studio 打开您的项目平台,然后尝试同步并更新 Gradle 并重建项目
  • 尝试运行npx react-native run-android 命令
  • 我仍然遇到同样的错误

标签: android react-native


【解决方案1】:

尝试在您放置 npx react-native run-android 的同一终端中,再次设置环境变量,如:

source $HOME/.zprofile(如果你使用 zsh)

source $HOME/.bash_profile(如果你使用 bash)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-02
    • 2019-01-17
    • 2017-11-15
    • 2021-08-28
    • 1970-01-01
    • 2020-11-15
    • 2012-01-18
    • 1970-01-01
    相关资源
    最近更新 更多