1

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?

4 Answers4

1

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.

Ace Falobi
  • 741
  • 1
  • 8
  • 25
  • This is the right answer here. This is the answer that works and should be marked as best. Changing from $JAVA_HOME to $STUDIO_JDK and adding it to the $PATH worked for me without need of downgrading my java version. But the issue is that it only worked on Android Studio Electric El and below. I tried it with other newer versions like Giraffe and Hedgehog, but I still got issues. – Daniel Iroka Aug 02 '23 at 15:04
0

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: How to set JAVA_HOME in Linux for all users

Thommy
  • 5,070
  • 2
  • 28
  • 51
0

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.

Hadrian
  • 1
  • 1
  • Please what latest version of Android Studio did you download and it did not break? I have about 5 android studio zip files but none of them is working. But I haven't tried this jdk solution though. – Daniel Iroka Aug 02 '23 at 09:57
  • Android Studio 2021.3.1 Dolphin just worked for me right now with java version 11.0.20. I need to use an android studio that supports AGP version 7.3.1. – Daniel Iroka Aug 02 '23 at 10:08
0

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