首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决这个错误,模拟器启动失败。原因:在React native中找不到仿真器作为` emulators list-avds`的输出?

如何解决这个错误,模拟器启动失败。原因:在React native中找不到仿真器作为` emulators list-avds`的输出?
EN

Stack Overflow用户
提问于 2019-12-16 19:25:33
回答 4查看 14.6K关注 0票数 4

我正在为移动应用程序创建react原生应用程序。我在构建react原生应用程序方面完全是新手。我正在使用ubuntu创建应用程序,并遵循以下链接来创建应用程序。https://facebook.github.io/react-native/docs/getting-started。有谁能解决这个问题吗?

在下面的阶段,我得到了错误:

代码语言:javascript
复制
cd AwesomeProject
npx react-native run-android

我的命令行中出现错误:

代码语言:javascript
复制
All-Series:~/Projects_App/AwesomeProject$ npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 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...
> Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
13 actionable tasks: 4 executed, 9 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /usr/lib/jvm/java-8-openjdk-amd64 contains a valid JDK installation.

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

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. 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:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /usr/lib/jvm/java-8-openjdk-amd64 contains a valid JDK installation.

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

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (/home/rupeevest/Projects_App/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
EN

回答 4

Stack Overflow用户

发布于 2020-04-10 23:02:35

转到您的react-native Project,然后转到android目录并使用此名称创建一个文件

local.properties

如果你在Windows上,打开文件并粘贴你的Android SDK路径,如下所示:

sdk.dir=C:\Users\UserName\AppData\Local\Android\sdk

我找到了正确的答案here

票数 4
EN

Stack Overflow用户

发布于 2019-12-20 06:58:17

当我遇到类似问题时,我使用的一个快速修复方法是运行

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

然后确保您的模拟器处于打开状态,并再次运行react-native run-android

票数 2
EN

Stack Overflow用户

发布于 2020-06-25 06:43:51

帮助我的是在Android Studio中打开项目,并在从旁边的模拟器下拉列表中选择模拟器后按下播放按钮。

此外,如果由于某种原因,该模拟器抛出错误,请尝试使用不同的电话安装另一个模拟器。希望这对某些人有帮助!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59355688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档