无法更新Android SDK软件包列表-Unity 2019.2.10f1 [英] Failed to update Android SDK Package List - Unity 2019.2.10f1

查看:229
本文介绍了无法更新Android SDK软件包列表-Unity 2019.2.10f1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试为Android平台导出游戏版本时,我开始出现此错误:

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

在项目设置"中-最低API级别和目标API级别均无法加载!虽然我使用了所有默认的Unity提供的设置来导出Android版本.这是说明这一点的图像:

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.

推荐答案

我在同时使用Unity 2019.4.18.f1/2019.2.21.f1的MacOS上遇到了相同的错误,经过一番混乱之后,我认为我可能会已经弄明白了.

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.

有时(不知道为什么),当您启动Unity时,Unity(或其他)开始将JAVA_HOME环境变量重置为字符串空.因此,即使您根据MacOS版本通过控制台或.bashrc/.zshrc设置JAVA_HOME,也仍然无法使用.

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.

有些帖子提到添加"/"到外部工具SDK路径的末尾.我认为这只是迫使Unity重新设置路径,这会使它工作一段时间.但是对我来说,错误只是在第二天才出现.

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.

我已将其永久修复,将编辑器脚本添加到编辑器"文件夹中,该脚本可在每次Unity启动/加载时更改JAVA_HOME环境变量.

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

这是MacOS的方法,只需将其粘贴到编辑器文件夹中的C#脚本中即可.

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

这篇关于无法更新Android SDK软件包列表-Unity 2019.2.10f1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆