Failed to update Android SDK Package List - Unity 2019.2.10f1

不羁岁月 提交于 2021-02-05 11:31:08

问题


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

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:

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.


回答1:


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"));
}


来源:https://stackoverflow.com/questions/61246933/failed-to-update-android-sdk-package-list-unity-2019-2-10f1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!