Error Building and Running 2D Mobile Game on Android

Hello, I am currently enrolled in the Unity C# Mobile Game Development course and I am running into an error:

Java Development Kit (JDK) directory is not set or invalid. Please fix it in Preferences → External Tools.

I went into External Tools and I really don’t know how to fix it, and trying several google searches and following several different suggestions, I am still at a loss. Could someone please help if possible. Thanks.

This could be an error with the installation of the modules not being installed or installed incorrectly and the error is a little misleading.
Close the project and go to the unity hub.
Then go to the version of unity you are using under the installs tab
Check to see if you have an android icon on it.
If you dont click the three dots and add the android module, If you do choose uninstall and then reinstall it and see if that helps solve the issue

Let me know how you get on

I have just tried starting from scratch by reinstalling the recommended version of Unity in the course, which is 2020.3.1f1, which resulted in an installation fail. This seems to be a recurring problem. Perhaps starting with that could help? Could it be a firewall problem?

My first google search result, which leads to the Unity forums, suggests that I try only installing the editor first, which I will try now.

1 Like

Installing the editor outside of the hub and then opening it from within the hub, the 3 dots do not provide an option for adding modules. I am attempting to do it within the editor through Build Settings → Android → Open Download Page

The download went through successfully, but building and running caused the same error. In preferences → external tools, the JDK seems to be set to an incorrect path and the SDK and NDK paths are not set at all. Gradle seems to be set correctly.

Hi Stebs,

I have been keeping an eye on this post as you progress and it does seem strange the issues you are having.

All i can really suggest at this point is uninstalling everything and making sure anything in %APPDATA% relating to unity and unity hub is also removed (Be very careful in this folder not to delete anything else andmake sure you uninstall before doing this)

Other than that you may have to reach out to unity for support as the automatic install of the engine from the hub and using the modules installed should be working correctly.

Hi Marc,

Thanks for the advice! I will try that.

Hi Marc,

So… communicating with Unity support was… subpar. Basically, I tried outlining the problem and sending screenshots when asked, and the general responses were slow and unhelpful.

I have been part of a game dev club/team for several years and took the problem to the leader of the club. After a couple of office hour type of appointments to address the problem, we finally figured out that having his downloaded packages uploaded to google drive, and then me transferring those zipped files to my google drive, unzipping in google drive, and then transferring to my hard drive worked. Perhaps there is a deep permissions problem going on on my hard drive?

Cheers.

1 Like

Privacy & Terms