app:compileDebugJavaWithJavac'。 > 无法找到 tools.jar 无法启动模拟器。原因:没有找到模拟器作为 `emulator -list-avds` 的输出
app:compileDebugJavaWithJavac'. > Could not find tools.jar Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`
当我在终端中使用这个命令时:
PS C:\web dev\practice-projects\react-native\myproject> react-native run-android --no-jetifier
我得到了整个错误:
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
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...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:compileDebugJavaWithJavac FAILED
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_warning
14 actionable tasks: 2 executed, 12 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 C:\Program Files\Java\jre1.8.0_271 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 39s
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
我的模拟器没有启动,我已经尝试了多个修复。我刚开始使用 react-native,不理解类似问题的警告或答案。请帮忙。
您可以通过几种方式 运行 您的应用,
- 始终有效 - 从 android studio 打开应用程序。 Select
Open existing project
和 select android
文件夹以打开项目,并在索引完成后从那里 运行。
- 不确定是否可行且不推荐(可能需要发布版本),但您可以将自动生成的 apk 文件拖到您的模拟器中进行安装。
- 将此行添加到
gradle.properties
文件,即 android/gradle.properties
。
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
。如果需要,替换 jdk 版本名称或目录。
注意 mac - 这不在您的用户目录中 library folder
因此在您的主驱动器位置搜索它们 - 应该类似于 machintosh hd
对于windows——只需替换org.gradle.java.home=
之后的路径即可。应该是 C:\Program Files\Java\jdk1.8.0_144
在我的例子中是因为 JAVA_HOME 路径找不到它。
关闭所有终端并打开一个新终端
在您的 Mac 上找到这样的目录:
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
可能会改变的是版本,但是一旦你拥有它,它就会在那个版本中运行
小路:
export JAVA_HOME = / Library / Java / JavaVirtualMachines /
jdk1.8.0_91.jdk/目录/首页
在我的例子中,我 运行 在反应本机项目的根目录下的这个命令:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
成功了。
当我在终端中使用这个命令时:
PS C:\web dev\practice-projects\react-native\myproject> react-native run-android --no-jetifier
我得到了整个错误:
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
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...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:compileDebugJavaWithJavac FAILED
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_warning
14 actionable tasks: 2 executed, 12 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 C:\Program Files\Java\jre1.8.0_271 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 39s
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
我的模拟器没有启动,我已经尝试了多个修复。我刚开始使用 react-native,不理解类似问题的警告或答案。请帮忙。
您可以通过几种方式 运行 您的应用,
- 始终有效 - 从 android studio 打开应用程序。 Select
Open existing project
和 selectandroid
文件夹以打开项目,并在索引完成后从那里 运行。 - 不确定是否可行且不推荐(可能需要发布版本),但您可以将自动生成的 apk 文件拖到您的模拟器中进行安装。
- 将此行添加到
gradle.properties
文件,即android/gradle.properties
。org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
。如果需要,替换 jdk 版本名称或目录。
注意 mac - 这不在您的用户目录中 library folder
因此在您的主驱动器位置搜索它们 - 应该类似于 machintosh hd
对于windows——只需替换org.gradle.java.home=
之后的路径即可。应该是 C:\Program Files\Java\jdk1.8.0_144
在我的例子中是因为 JAVA_HOME 路径找不到它。
关闭所有终端并打开一个新终端
在您的 Mac 上找到这样的目录: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
可能会改变的是版本,但是一旦你拥有它,它就会在那个版本中运行 小路: export JAVA_HOME = / Library / Java / JavaVirtualMachines / jdk1.8.0_91.jdk/目录/首页
在我的例子中,我 运行 在反应本机项目的根目录下的这个命令:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
成功了。