将Unity升级到2021.3.36f1, 再次打开项目,结果出现“CommandInvokationFailure: Failed to update Android SDK package list.”这样的警告,查看SDK版本最高只有到30,这应该就是Unity自动升级SDK的时候出现了错误,导致失败。经过一番搜素后找到了解决方法。

解决方法如下:

链接:解决方案

方法小结:

1. elevate any text editor as administrator
2. open sdkmanager.bat at “C:\Program Files\Unity\Editor\YOUR_VERSION\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\latest\bin”
3. find code here

set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%~dp0\..add \" to %~dp0\.. like below
set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir="%~dp0\.."4. back to Unity and try building again