CommandInvokationFailure: Failed to update Android SDK package list.

Just updated to 2021.3.34f1. Using all default Unity supplied SDKs.

Unable to list target platforms. Please make sure the android sdk path is correct.
Error: Could not find or load main class Files\Unity\Hub\Editor\2021.3.34f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\2.1\bin\\..
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEditor.Android.CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct.
C:\Program Files\Unity\Hub\Editor\2021.3.34f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\2.1\bin\avdmanager.bat list target -c
1 Like

We struggling with the same problem

2 Likes

I downgraded to 2021.3.33f1 and it works again

I need play core libs update unfortunatly bcz i ma trying to fix PAD problems(

We just updated, and have the same issue.

Could you attach editor.log?

I have the same problem. While it worked on 2021.3.32, I encountered errors when upgrading to 2021.3.34(Windows10).
However, I found that this issue only occurs when the Unity Editor is installed in the “Program Files” directory. In my case, changing the Hub settings to install it to “C:\Unity\Editor” resolved the problem. As long as I reinstall into the “Program Files” folder, I saw the error messages.
The log when the error occurred is as follows:

C:\Program Files\Unity\Hub\Editor\2021.3.34f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\2.1\bin\sdkmanager.bat --list

Environment Variables:
PROCESSOR_ARCHITECTURE = AMD64
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2021.3.34f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK

(skip)

stderr[
エラー: メイン・クラスFiles\Unity\Hub\Editor\2021.3.34f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\2.1\bin\\..が見つからなかったかロードできませんでした
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c344dfa67884d4ca623f814e4a08809>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c344dfa67884d4ca623f814e4a08809>:0)
UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, System.Boolean updateCommand, System.String errorMsg, System.String toolsDir, System.String[ ] warningsToIgnore) (at <2c344dfa67884d4ca623f814e4a08809>:0)
UnityEditor.Android.AndroidSDKTools.ListComponentsVersions () (at <2c344dfa67884d4ca623f814e4a08809>:0)
UnityEditor.Android.SDKManager.UpdatePackagesList () (at <2c344dfa67884d4ca623f814e4a08809>:0)
UnityEditor.Android.SDKManager.ListAvailable (UnityEditor.Android.SDKManager+Component type) (at <2c344dfa67884d4ca623f814e4a08809>:0)
UnityEditor.Android.PlayerSettingsEditorExtension+<>c__DisplayClass127_0.<StartGettingReleasedAPILevels>b__0 () (at <2c344dfa67884d4ca623f814e4a08809>:0)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <7e05db41a20b45108859fa03b97088d4>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <7e05db41a20b45108859fa03b97088d4>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <7e05db41a20b45108859fa03b97088d4>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <7e05db41a20b45108859fa03b97088d4>:0)
System.Threading.ThreadHelper.ThreadStart () (at <7e05db41a20b45108859fa03b97088d4>:0)
UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)
2 Likes

"install it to "C:\Unity\Editor" resolved the problem."

Thanks a lot. This helped to resolve this problem.

I bet it has the same problems as https://discussions.unity.com/t/835271

1 Like

Hey, it seems there’s a bug in Google’s Android SDK:

Workaround 1:
Patch Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\2.1\bin\sdkmanager.bat

Change

set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%~dp0\..

to

set DEFAULT_JVM_OPTS="-Dcom.android.sdklib.toolsdir=%~dp0\.."

Workaround 2:

  • Remove Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools

Workaround 3:
P.S Unity 2022.2 and up uses cmdline-tools 6.0, where this bug was fixed by Google.

27 Likes

This solution works. Thank you so much for your help on this!

2 Likes

Thank you so much for your help! I tried this and works.

Works like a charm thank you!

What's the problem with unity .I think unity team didn't bother to test their products.
9622205--1366199--upload_2024-2-3_23-46-10.png

9622205--1366199--upload_2024-2-3_23-46-10.png

2 Likes

The workaround is all right. But it’s sad to see it wasn’t fixed in 2021.3.35f1.

The workaround doesn't work on macOS.

2 Likes

Can you share Editor.log with error?

This is from my Editor.log file:

.....
CommandInvokationFailure: Failed to update Android SDK package list.
/Applications/Unity Editor/2021.3.34f1/PlaybackEngines/AndroidPlayer/SDK/cmdline-tools/2.1/bin/sdkmanager --list

Environment Variables:
DEBUG_ENV_VAR = UnityHub
XPC_FLAGS = 0x0
__CFBundleIdentifier = com.unity3d.unityhub
...
COMMAND_MODE = unix2003
...
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
JAVA_HOME = /Applications/Unity Editor/2021.3.34f1/PlaybackEngines/AndroidPlayer/OpenJDK
...
USER =
MallocNanoZone = 0
LOGNAME =
__CF_USER_TEXT_ENCODING = 0x1F5:0x0:0x3
...
PATH = /usr/bin:/bin:/usr/sbin:/sbin
SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.sH5x6TCdTe/Listeners
...
HOME = /Users/
TMPDIR = /var/folders/dr/q5910vpn30b8dw4vr7f8zkj40000gn/T/
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
...
SHELL = /bin/zsh
...

stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Fehler: Hauptklasse Editor.2021.3.34f1.PlaybackEngines.AndroidPlayer.SDK.cmdline-tools.2.1 konnte nicht gefunden oder geladen werden
]
stdout[

]
exit code: 1
  at UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x00033] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x0002d] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, System.Boolean updateCommand, System.String errorMsg, System.String toolsDir, System.String[] warningsToIgnore) [0x00096] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.AndroidSDKTools.ListComponentsVersions () [0x00086] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.SDKManager.UpdatePackagesList () [0x00079] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.SDKManager.HighestVersionInstalled (UnityEditor.Android.SDKManager+Component tool) [0x00001] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKToolsDetector.GetVersion () [0x00006] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector.Detect (System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress) [0x0002b] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector detector) [0x00007] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) [0x00172] in <2c344dfa67884d4ca623f814e4a08809>:0
  at UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) [0x00078] in <2c344dfa67884d4ca623f814e4a08809>:0
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[], Boolean)
UnityEditor.DefaultBuildMethods:BuildPlayer(BuildPlayerOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:170)
UnityEditor.BuildPlayerWindow:CallBuildMethods(Boolean, BuildOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun(Boolean) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:187)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun() (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:181)

(Filename: /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs Line: 181)

Unloading 34 Unused Serialized files (Serialized files now loaded: 0)
Unloading 42 unused Assets / (52.5 KB). Loaded Objects now: 7162.
Memory consumption went from 168.1 MB to 168.1 MB.
Total: 41.610017 ms (FindLiveObjects: 0.600219 ms CreateObjectMapping: 0.535009 ms MarkObjects: 40.243026 ms  DeleteObjects: 0.230719 ms)

Build Finished, Result: Failure.
Unloading 0 Unused Serialized files (Serialized files now loaded: 0)
Loaded scene 'Temp/__Backupscenes/0.backup'
    Deserialize:            8.101 ms
    Integration:            248.908 ms
    Integration of assets:  0.008 ms
    Thread Wait Time:       0.024 ms
    Total Operation Time:   257.040 ms
Unloading 0 unused Assets / (0.9 MB). Loaded Objects now: 7090.
Memory consumption went from 166.3 MB to 165.4 MB.
Total: 31.580643 ms (FindLiveObjects: 0.587648 ms CreateObjectMapping: 0.413192 ms MarkObjects: 30.441520 ms  DeleteObjects: 0.137280 ms)

Build completed with a result of 'Failed' in 3 seconds (2608 ms)
UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:193)
UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun (bool) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:187)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun () (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:181)

(Filename: /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs Line: 193)

UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ce] in /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:194
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs:100)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun (bool) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:187)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun () (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:181)

(Filename: /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindowBuildMethods.cs Line: 100)

2024-02-08 19:00:14.547 Unity[2576:99736] NSEventModifierFlagFunction specified to -setKeyEquivalentModifierMask: for item <NSMenuItem: 0x7fa9d9255dc0 UI Toolkit Debugger, ke='Command-F5'>, but is only supported for system-provided menu items; will not be used
.....

Do you get the same error with Unity 2022.3, it uses cmd-linetools 6.0, wondering if Google fixed this issue there ?

Yes, same issue in 2022.3.14f1 except it says : Editor.2022.3.14f1.PlaybackEngines.AndroidPlayer.SDK.cmdline-tools.6.0 not found

I guess your only option for now - is to install Unity to path without spaces, or move Android SDK to path without spaces.

3 Likes