首页 > 解决方案 > Linux 上 Pycharm 专业版中的 React-Native Android 和 iOS 模拟器

问题描述

我正在尝试在 Pycharm(在 Linux 上)中运行 React-native 应用程序,但我不明白如何安装 Android 和 iOS 模拟器。我试图按照这里的教程进行操作,但显然失败了。当我尝试在 Android 上启动时,react-native run-android出现以下错误:

react-native run-android
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 8 workers...
info JS server already running.
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.2/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/media/dev/test/android/local.properties'.

* 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

同样,当我尝试使用 iOS 时,我收到此错误:

error Could not find "Podfile.lock" at /media/dev/test/ios/Podfile.lock. Did you run "pod install" in iOS directory?
info Found Xcode project "reactNative_tests.xcodeproj"
error Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues. Run CLI with --verbose flag for more details.
Error: spawnSync xcrun ENOENT
    at Object.spawnSync (internal/child_process.js:1067:20)

所以我的问题很简单:如何在 Pycharm 中安装这些模拟器?

标签: react-nativepycharmandroid-emulatorreact-native-androidreact-native-ios

解决方案


推荐阅读