Android Studio 在 WSL 上无法启动(找不到 JRE)。

huangapple go评论67阅读模式
英文:

Android Studio doesn't start on WSL (No JRE found)

问题

Step 1. 在我的WSL上安装了Java,通过运行以下命令:

sudo apt install default-jdk

当我运行 java --version 时,它显示 openjdk 11.0.18 2023-01-17

Step 2. 在我的Windows 10上安装了 VcXsrv X Server,并进行了配置以确保它正常工作(我成功地通过在终端中运行 "xcalc" 启动了Ubuntu的计算器)。

Step 3. 下载了Android Studio的Linux包并解压到我的主目录子文件夹中。

现在我试图通过运行 "sh studio.sh" 来启动它,但出现了来自VcXsrv X Server的错误消息:

无法启动Android Studio:未找到JRE。请确保$STUDIO_JDK、$JDK_HOME或$JAVA_HOME指向有效的JRE安装。

我应该怎么做?它是否需要我在Windows上安装JDK并在那里设置环境变量?

英文:

Step 1. Installed java on my WSL by running

sudo apt install default-jdk

when I run java --version it gives me openjdk 11.0.18 2023-01-17

Step 2. Installed VcXsrv X Server on my Windows 10. Configured it so I'm sure that it works (I mananged to start Ubuntu's calculator on it by running "xcalc" in the terminal)

Step 3. Downloaded Android Studio linux package and unzipped it in my home directory subfolder.

Now I am trying to start it by running "sh studio.sh" but an error from VcXsrv X Server is popping out:

> Cannot start Android Studio: No JRE found. Please make sure
> $STUDIO_JDK, $JDK_HOME, or $JAVA_HOME point to valid JRE installation.

What am I supposed to do? Does it need me to install JDK on Windows as well and set env variables there?

答案1

得分: 1

我在寻找解决方法时遇到了这个错误和这个问题。

您可以通过将$STUDIO_JDK变量设置为$JAVA_HOME路径来解决此问题。希望这对您也有所帮助。

英文:

I encountered this error and this question while searching for a solution.

You can fix this by instead setting the $STUDIO_JDK variable to the $JAVA_HOME path. Hope this helps you also.

答案2

得分: 0

Running java binary does not tell you about JAVA_HOME variable. Run echo $JAVA_HOME to see if it's present, if not check here how to set it: https://stackoverflow.com/questions/24641536/how-to-set-java-home-in-linux-for-all-users

英文:

Running java binary does not tell you about JAVA_HOME variable. Run echo $JAVA_HOME to see if its present, if not check here how to set it: https://stackoverflow.com/questions/24641536/how-to-set-java-home-in-linux-for-all-users

答案3

得分: 0

我曾经在同一个位置待了几个星期,但我成功通过将Studio降级到版本2021.1.1和运行sudo apt install openjdk-11-jre来降级Java到版本11来解决了这个问题。有关如何以及何时执行此操作,请查看此链接

我的下一步是找出我可以使用的最新版本,而不会破坏现在正常运行的内容。

英文:

I was in the same position for weeks, but I managed to get round it by downgrading Studio to version 2021.1.1

And downgrading java to version 11 by running sudo apt install openjdk-11-jre. Check this out for further info on how and when to do this.

My next steps is to find out which is the latest version of each that I can use without breaking what now works.

答案4

得分: 0

I had the same issue but this helps me: 在Windows 10子系统Linux上运行Android Studio.

Main point:

  1. 除了VcXsrv之外,还需要在Unix端安装xfce4。
  2. 使用以下命令安装缺失的库:sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
  3. 我还在/etc/profile中添加了export DISPLAY=:0,而不是在文章中所说的export DISPLAY=[unix ip]:0

经过这一切,我成功在WSL上运行了Android Studio。

英文:

I had the same issue but this helps me: Can I run android studio on windows 10 Subsystem Linux.

Main point:

  1. In addition to VcXsrv you need to install xfce4 on the unix side
  2. Install missing libraries with: sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
  3. I also added export DISPLAY=:0 in /etc/profile instead of export DISPLAY=[unix ip]:0 like it says in the article

After all this I managed to run android studio on WSL

huangapple
  • 本文由 发表于 2023年5月11日 16:00:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225337.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定