Failed to update Android SDK package list error when using SDK installed with unity.

On Windows, java uses an environment variable, one named JAVA_HOME and it also might use the Path variable to find the java binaries.

https://docs.oracle.com/en/database/oracle/r-enterprise/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0

New Unity comes bundled with Java so it shouldn’t need any external java “stuff”.
Removing them should fix any java issues, as long as you choose to install and use the bundled java.

However there is another bug on unity that leaves some path bars inverted and apparently this bugs the java usage.

Java 9 (JDK 9) support by Unity Android page-3#post-5724547

So I now just use a script to fix this stuff automatically…

string newJDKPath = EditorApplication.applicationPath.Replace("Unity.exe", "Data/PlaybackEngines/AndroidPlayer/OpenJDK");

        if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
        {
            Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
        }

Put in on a static constructor on a class marked with [InitializeOnLoad] on the Editor folder of your project.

12 Likes