17

Can Android Studio use OpenJDK 1.8 or does it require Oracle JDK on Linux? It would be easier to use OpenJDK because it comes installed on Fedora.

I'm running 64 bit Fedora-23 linux with Android Studio 1.5.1.build AI-141.2456560 on an Intel Haswell i7 chip.

$ java -version
openjdk version "1.8.0_72"
OpenJDK Runtime Environment (build 1.8.0_72-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)

$ ./java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

$ uname -a
Linux localhost.localdomain 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ more build.txt 
AI-141.2456560

3 Answers 3

4

No, just as the android documentations says, Oracle JDK is required. I got a "null pointer exception" on render on when running a simple build of an empty project with openJDK. This error probably came from the IDE, not the build of the APK file.

After running studio with Oracle's JDK, it all worked properly with no change to the code.

Actually it gets more complicated than that because, I have both versions on my system. Oracle JDK is used to launch the studio.sh file, but inside studio I still have the OpenJDK specified under "Project Structure> JDK" as:

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.72-4.b15.fc23.x86_64

I'll report back if this hybrid situation fails.

4
  • 1
    I don't see where it says that in the "documentation". The Android Studio page now just says "Java Development Kit (JDK) 8" for the requirements for Linux (developer.android.com/studio/…)
    – Maks
    Jun 7, 2016 at 2:07
  • It does when you launch the installer. I am running OpenJDK on manjaro linux and the installer tells you the following: SYSTEM HEALTH OpenJDK shows intermitten performance and UI issues. We recommend using the Oracle JRE/JDK" Sep 11, 2016 at 8:28
  • 2
    i have read this section in developer.android.com: developer.android.com/studio/intro/studio-config#jdk and it recommends to use openjdk.
    – Abilogos
    Jun 17, 2020 at 7:41
  • Wrong information ! There is no such thing in the documentations of android. openjdk is suggested
    – SAYE
    Sep 12, 2021 at 20:22
4

I am using Android Studio since version 1.0 (currently 2.0 beta) on Fedora 64 bit (currently 23) and OpenJDK. It used to display a warning saying something like "OpenJDK is not supported, do not open bug reports if something goes wrong", I don't know if it it still does (I may have clicked on "Don't show this again").

There was also a warning about libinput but I think it is not related to OpenJDK.

Anyway in my case it works quite well, as far as I can remember I did not have to use special tricks. Obviously your mileage may vary.

4

Below found in android docs

OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

shout out to @Abilogos

Docs: https://developer.android.com/studio/intro/studio-config#jdk

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.