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

JAVA_HOME: does not contain java which is required to process Android libraries

Discussion in 'Editor & General Support' started by roesler13, May 6, 2020.

  1. roesler13

    roesler13

    Joined:
    Dec 9, 2019
    Posts:
    3
    Hello, I am trying to make an Android build of my game, but my editor does not read the Android module that I installed for it. Im using 3.9f1, but appears to be loading something from 3.0b6 in the error message.

    Error Message on loading a project:
    JAVA_HOME environment references a directory (C:/ProgramFiles/Unity/Hub/Editor/2019.3.0b6/Editor/Data/PlaybackEngines/AndroidPlayer\OpenJDK)
    that does not contain java which is required to process Android libraries

    Things Ive tried
    - Completely reinstalling 3.9f1 engine with the Android module
    - Set my Environment Variables. Variable name: JAVA_HOME Variable value: C:\Program Files\Java\jdk-14.0.1
    - Deleting the AndroidPlayer folder inside PlaybackEngines folder and manually download the Android module and install it

    After reinstalling the engine or Android module it still stays "You are missing the recommended JDK. Install the recommended version using Unity Hub."

    I've made android builds in the past with no problems but I appear to be missing something here.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Did you install Android Build Support from Unity Hub? Unity most likely expects a specific version of Java to be there, which you can get via Unity Hub.

    You can find this in Installs -> <your unity version> -> click the "..." menu -> Add Modules -> Android Build Support

    You should install all of it but there is specifically OpenJDK under there too.
     
    roesler13 likes this.
  3. roesler13

    roesler13

    Joined:
    Dec 9, 2019
    Posts:
    3
    Thanks for the reply. Yes, I have Android Build Support, Android SDK & NDK Tools and Open JDK all listed as Installed
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    I think Unity might use a special "builder" user. That user will have different environment variables set than your user. This doesn't solve your problem but it might explain why JAVA_HOME would be different even if you set JAVA_HOME yourself. I think it's supposed to set JAVA_HOME when you pick your JDK in Android build settings.
     
  5. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Sorry! I have the same issue but I don't understand how you solved this problem. question.png
     
  6. EKO_LX

    EKO_LX

    Joined:
    Dec 25, 2020
    Posts:
    45
    Have same issue with Unity 2020.3.0f1 on Mac X OS. Even SDK point to right directory I'm getting
    JAVA_HOME environment references a directory (/Applications/Unity/Hub/Editor/2019.4.15f1/PlaybackEngines/AndroidPlayer/OpenJDK) that does not contain java which is required to process Android libraries.

    As I understand that path was set automatically when I was installing Unity 2019. But currently I removed that version.
    Also would be worth to mention that I installed the Unity 2020.3.0f1 from installer not Unity Hub, since it wasn't working from there.
    This error I started getting after installing Facebook SDK.
    I tried this https://stackoverflow.com/questions...environment-references-a-directory-in-unity3d as well but was unsuccessful.
     
  7. arslanmughal

    arslanmughal

    Joined:
    Dec 22, 2015
    Posts:
    4
    I am also facing same problem after installing Facebook SDK. Tried unchecking and rechecking the android SDK and JDK checks from Preferences of Unity, but find no luck.
     
    rory_playcebostudios likes this.
  8. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    I was able to fix by going into preferences, copying the (correct) pre-generated paths for all the materials, and pasting them into the fields after disabling the 'installed with Unity' checkboxes. Automated service resolution keeps looking for a directory that doesn't match the project version and didn't exist anymore.
    upload_2021-7-12_10-26-45.png
    I think my case was triggered by upgrading the project and deleting the previous unity version. The path resolution code is stuck looking for 2018 even though everything in the editor window looks correct. I believe the project started in 2018 so perhaps some value in the code got stuck on it?
     
    JoelChala, L0tan and Lorrak like this.
  9. Akib1314

    Akib1314

    Joined:
    Jul 12, 2017
    Posts:
    4
    thanks a lot for your solution, it works well.