gpt4 book ai didi

linux - 设置时错误JAVA_HOME未设置

转载 作者:太空宇宙 更新时间:2023-11-04 09:11:25 25 4
gpt4 key购买 nike

当我尝试运行命令时:

    react-native run-android

我收到这个错误:

Scanning folders for symlinks in /home/x/myApp/node_modules 
(10ms)
JS server already running.
Building and installing the app on the device (cd android &&
./gradlew installDebug)...

ERROR: JAVA_HOME is not set and no 'java' command could be
found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device
connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

JAVA_HOME 设置正确(我认为)

java -version 

echo $JAVA_HOME 

返回正确的结果。截屏: 1JAVA_HOME设置在/etc/environment/etc/profile/bashrc/bash_profile

我也做了 source/bashrc 等

虚拟设备也已连接。我可以在 android-studio 中打开这个项目并生成 apk

最佳答案

确保你已经安装了java

之后

如果你的路径是错误的这样做:

export | grep JAVA

结果:java home 被设置成什么

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home

按照路径看目录是否正确我在我的终端里做了这个:

open /Library

然后我去了/Java/JavaVirturalMachines 原来我有错误的“jdk1.8.0_202.jdk”文件夹,还有另一个数字...... 4. 你可以使用这个命令来设置 java_home

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home

关于linux - 设置时错误JAVA_HOME未设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55778898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com