【问题标题】:Failed to run React-Native on Android无法在 Android 上运行 React-Native
【发布时间】:2020-10-01 02:20:17
【问题描述】:

在此处遵循 React Native 的官方指南后,我收到此错误: https://reactnative.dev/docs/environment-setup 我试图打开模拟器并再次运行命令,但我得到了同样的错误。

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
/bin/sh: adb: command 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...

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

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

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```

【问题讨论】:

  • 您没有安装任何模拟器。您可以在 Android Studio 中安装模拟器或将您的安卓手机连接到您的机器进行测试。
  • 如果模拟器或安卓设备已经连接,请检查您的adb路径是否配置正确。

标签: android react-native android-studio


【解决方案1】:

你应该连接一个安卓设备(激活开发者模式)或者打开一个模拟器 Android工作室的AVD经理

【讨论】:

    【解决方案2】:

    请在项目文件夹中的终端运行以下命令

    export ANDROID_HOME=/Users/{yourusername}/Library/Android/sdk
    export PATH=$ANDROID_HOME/platform-tools:$PATH
    export PATH=$ANDROID_HOME/tools:$PATH
    

    然后npm run android

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-16
      • 2020-05-16
      • 1970-01-01
      • 2021-05-10
      • 2017-01-14
      • 1970-01-01
      • 2021-02-23
      相关资源
      最近更新 更多