SetupAndroid.bat fails when executed from Install SDK button (but it doesn't if executed from Windows Command Line)

Hi there! I’m a very newbie Unreal user and I am working on a VR project with Unreal Engine 5.4 to develop a VR game for Oculus Quest 3.

I’m trying to compile my project, but as far as understood I need to interface first my UE with Android Studio and install Android SDK, but currently I am facing the following issue: when I click on Install SDK button from Platforms->Android the installation fails with the following error:
ERROR: Command C:\Program Files\Epic Games\UE_5.4\Engine\Extras\Android\SetupAndroid.bat android-33 33.0.1 3.22.1 25.1.8937393 -noninteractive failed [Exit code 4, working dir = C:\Program Files\Epic Games\UE_5.4\Engine\Extras\Android]

If I execute the same file from Windows command line it doesn’t fail.

How can I fix it?

I already found and tried some solutions changing like this part of the .BAT:
set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\8.0\bin\sdkmanager.bat
IF EXIST “%SDKMANAGER%” (
** echo Using sdkmanager: %SDKMANAGER%**
) ELSE (
** set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\8.0\bin\sdkmanager.bat**
** IF EXIST “!SDKMANAGER!” (**
** echo Using sdkmanager: !SDKMANAGER!**
** ) ELSE (**
** echo Unable to locate sdkmanager.bat. Did you run Android Studio and install cmdline-tools after installing?**
** %PAUSE%**
** exit /b 3**
** )**
)

But this part seems ok now since it fails with the error 4 and not the 3.