Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to update Android SDK Package List - Unity 2019.2.10f1

When I try to export the game build for the Android platform, I started getting this error:

enter image description here

Within the Project Settings - Minimum API Level and Target API Level not get loaded anyhow! While I have used all default Unity provided settings to export Android build. Here is the image to illustrate this:

enter image description here

Now what to do to solve this error?

I have already read all the threads related to same problem but overall I can't able to find the solution that actually worked for me.

like image 802
Siddharth Avatar asked Dec 23 '22 18:12

Siddharth


2 Answers

  1. Project Settings > Player > Target API Level: Change "Automatic" to "Android 11" (or else)
  2. Play once and Stop.
  3. Change target api level to Automatic.

I don't know if the problem is the same, but this is how I handle it every time.

Edit: Now I just do this; I open the Other Settings Tab in Player Settings. Error appears in console. I Play and Stop it once and the error goes away (No need to change API Levels)

like image 61
sadrag Avatar answered Dec 30 '22 11:12

sadrag


I just got the same error on MacOS using both Unity 2019.4.18.f1/2019.2.21.f1 and after a lot of messing around I think I might have figured some of it out.

At times ( don't know why ) Unity ( or something else ) starts resetting the JAVA_HOME environment variable to string empty when you start Unity. So even if you set JAVA_HOME via console or .bashrc/.zshrc depending on MacOS version it still doesn't work.

Some posts mentioned adding "/" to the end of the external tools SDK path. I think that just forces Unity to set the path again which makes it work for a while. But for me the the error just came back the second day.

I permanently fixed it adding an editor script to the Editor folder that changes the JAVA_HOME environment variable every time Unity starts/loads.

Here's the method for MacOS, just paste it in a C# script in the editor folder.

[InitializeOnLoadMethod]
static void SetJavaHome()
{
    //Debug.Log(EditorApplication.applicationPath);

    Debug.Log("JAVA_HOME in editor was: " + Environment.GetEnvironmentVariable("JAVA_HOME"));

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

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

    Debug.Log("JAVA_HOME in editor set to: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
}
like image 39
filo Avatar answered Dec 30 '22 12:12

filo