Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question JDK 17 not recognized - what version do I need for Unity 2021.3.17?

Discussion in 'Android' started by Kurt-Dekker, Oct 3, 2023.

  1. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,560
    I'm using Unity 2021.3.17. It installed OpenJDK 1.8. However, attempts to build with it from within Unity result in this error:

    Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0


    I installed JDK 17 and put it here:

    /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home


    The contents of that Home folder appear analogous to the 1.8 home (has a bin/, etc.).

    The above path was entered into the External Tools path in Unity.

    Running
    bin/java -version
    confirms:

    java version "17.0.8" 2023-07-18 LTS


    But all Unity gives me is:

    UnityException: JDK not found
    Java Development Kit (JDK) directory is not set or invalid. Please, fix it in Edit / Unity -> Preferences -> External Tools


    What version of Java am I supposed to use for Unity 2021.3.17?

    Can I run the built-in OpenJDK one from Unity or is it always going to complain about runtime mismatches running the current Android toolchain tools?
     
  2. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    711
    did you let unity install it as the modules? as normally it all works then
     
  3. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,817
    AFAIK, Unity currently supports until JDK 11 only (JDK 11 support started from Unity 2022).

    To know what versions a specific unity version expects, you need to
    1. Go the install folder of Unity
    2. Open modules.json file
    3. Search for open-jdk

    I'm sharing a screenshot of on the left, it supports JDK 8 and on the right JDK 11
    Screenshot 2023-10-04 at 9.53.18 AM.png

    Actually, I'm not aware of the modules.json file but someone here on forum shared it in a different context. I will tag them once I find the post. Whole credits to that person!

    Cheers,
    VB Team
     
    Kurt-Dekker likes this.