Android build fails with "UnityException: JDK not found"

Setup
Unity 2019.3.0b12 (Pro License)
Ubuntu 18.04 (Bionic Beaver)

OpenJDK
openjdk version “1.8.0_222”
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

Hello,

we are currently setting up our Jenkins server to build Android packages with Unity.
We had to install the OpenJDK, Android SDK and Android NDK package manually because those provided by Unity are not recognized as valid and thus do not work.

I am unsure whether this topic fits better into the “Android” or “Unity Beta Release” section, but since the the affected elements here involve the Android tool chain I decided to go with this section.

The error which is blocking the build is

Unfortunately the default settings (recommended) in “Preferences / External Tools” do not work.
This is what it looks like after a fresh install with the Android tool chain being installed.

5203307--517544--mod.png

The editor accepts the manual path in the editor but still throws the above mentioned exception when running a build. The path is routed to the global java installation since the link to the Unity provided OpenJDK under “Data/PlayackEngines/AndroidPlayer/OpenJDK” is refused by the Editor. The same is also valid for the NDK and the SDK.

5203307--517532--man.png

The JDK is correctly added to the PATH and the JAVA_HOME variable is set as well.

While we haven’t tried all version, this behavior is also present using Unity 2019.3.0b(8/9/10/11).
I am unsure where to look next.
Any help is greatly appreciated.

Alexander

I have the same issue on Ubuntu 19.10 and Unity 2019.3.0b12 (Personal Licence).

Is there a way to set these paths from code ?
I have tried setting these variables using the method described in this link to no avail.
https://answers.unity.com/questions/495735/setting-android-sdk-path-in-environment-variable.html?_ga=2.97528728.604420094.1574194278-1664094602.1508320819

Unity Issue Tracker - [Linux] Unity Hub sets up Android SDK, NDK and JDK incorrectly on Linux I found that issue and voted. Except the problem with the JDK, everything works ok.

@PsychoPhysicist What JDK version do you have installed?

@PsychoPhysicist Thanks for the link, it actually contains workarounds which worked in my case.
It is, however, sad and obvious from the issue report that the android build tool installation for linux, which includes broken permissions, missing folders, invalid paths and ignored editor settings has never seen a single QA test.

Weird thing is, I have this issue, but only after installing Easy Mobile Pro into a project…

@MADiFold All of the issues have been resolved by Unity at UnityHub V2.3.0.

I have easy mobile as well, and even with UnityHub V2.3.0 I’m still getting the same error with Easy Mobile Pro…

I get this error constantly and have to go into external tools, untick use JDK from hub and then try and remove the url that’s there. Then tick use JDK from hub again.

I have to do this multiple times a day…

Regarding Easy Mobile, I can also confirm this is a problem for me.

this is what worked for me maybe it’ll work for you guys . so in my case i messed up the path during the installation of both the HUB ant the unity versions themselves and at the time i only have version 2019.3.3f1 installed with the sdk, ndk, and jdk so before trying to update to newer versions like 2019.3.8f1 and 2019.3.10f1 i fixed the path issues but the jdk wont downlod into the newer versions even from the hub so i copied the jdk from the older verisons into the jdk folder of the newer versions and that fixed it for me

im getting tired with this engine many strange issue make me frustated

Unity developers have no idea how hard for a simple person to install and make a simple build in unity, this new unity is very confusing, i download it maybe 8 times consume 6 hours, trial and error, it will not work if you dont google or youtube it. this devs making software they dont test if its working. I installed the module for hours expecting I can finaly f*** build in android. yet another bug again wth I consume 2 freakin days just to make this unity work!!!

In my mac unity 2019.4 crashes even at start shutting down my mac mini multiple times!
Its like unity devs are selling for example a car when the drive press the start it wont work you need a mechanic first lol,
pls improve Unity its way better before. normal student or professional will not understand this kind of things bugging just for the first install.

tataygames, how did you build your project? I have the same problem,… :frowning: did you change the jdk?

this really is bullshit. I dont want all your stupid fucking extra features. I just want to make 1 change to my analytics code and rebuild my app. Think I can do this? Tried 3 different versions of unity now for this 1 app and countless hours messing around with stuff.
JDK not installed? JDK not found. Fuck off it is. I installed it myself. Unity Hub also installed OpenJDK but still the editor just wont detect it.
Guys just make a product that works. This is ridiculous

I was having this issue.
Turns out my virus scanner (Avast) was silently blocking the install of OpenJDK.

If I look at the modules in the Hub, I can see that OpenJDK is ticked, but it does not say installed.
This gives an indication that something failedI.
I really wish the Hub would shout at the point it fails to install a module though rather than letting it silently fail and keeping the info hidden away, then people might be able to figure out it these issues earlier.

So my solution was:

  • Disabled the virus scanner
  • Open Unity Hub
  • Go to Installs
  • Click the 3 dots
  • Select Add Modules
  • Expand Android Build Support.
  • Untick and Retick OpenJDK
  • Hope it now installs (it did for me)

So my solution was:

  • Disabled the virus scanner
  • Open Unity Hub
  • Go to Installs
  • Click the 3 dots
  • Select Add Modules
  • Expand Android Build Support.
  • Untick and Retick OpenJDK
  • Hope it now installs (it did for me)[/QUOTE]

Actually, I can’t Untick and Retick OpenJDK, do u have any alternative solution?

UPDATE: never mind, I have found the solution, just edit this file (make selected=false for the specified module) : C:\Program Files\Unity\Hub\Editor\2020.2.3f1/modules.json

Hi, what I did is I uninstall everything, and install unity hub, then on unity hub, you can install the version of unity you like I select unity 2019.4.16 which is stable. the only bug is when you click the sprite on the sprite renderer in the inspector it does not locate you to the source image.

When you open unity hub, click the tab install, and you can install the version of unity you like.
Pls see attached file.

And if your using mac, on unity hub on the projects tab. theres a 3 dot there click it then, click advance project settings.
then in put this word: -force-metal

This link will show you how to build successfully on android.
https://discussions.unity.com/t/745537/26

7093660--844930--Screen Shot 2021-04-30 at 5.17.47 PM.png

Problem fixed here :