Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "JAVA_HOME environment references a directory" in unity3d

I have a problem showed on this screenshot: https://imgur.com/a/VGHrpVV

The problem has appeared when I imported GoogleMobileAds package to insert AdMob ads to my project. I tried to create 2 local variables "JAVA_HOME" and "PATH" in environment variables using this guide https://null-code.ru/solution/157-reshenie-exception-jar-not-found-windows.html , but it doesn't help me.

like image 857
JediMan4ik Avatar asked Jun 23 '19 08:06

JediMan4ik


People also ask

How do I set the JAVA_HOME environment variable?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.

How do you fix JAVA_HOME is not set and no Java command could be found in your path?

Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable. Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply. You are done. Just restart android studio and gradle command will work.

What is JAVA_HOME environment variable?

JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.


1 Answers

It is a Unity bug. To fix:

Edit->Preferences->External Tools
Uncheck Android SDK Tools Installed with Unity (recommended)
Press Browse -> It might update the filepath
Recheck Android SDK Tools Installed with Unity (recommended)

Then:

Assets->Play Services Resolver->Android Resolver->Resolve

This has been tested and works with Unity 2019 and Unity 2020.

like image 196
Evorlor Avatar answered Oct 11 '22 13:10

Evorlor