Hello everyone.
So, I’ve been trying to set the android.bat file for unreal engine 5 by following the documentation online but I’m having a lot of issues. After I followed the instructions of unreal documentation that say to change the set SDKMANAGER with this set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\8.0\bin\sdkmanager.bat"
the file stopped working. I try to open up but it closes immediately. I’m a little bit lost, could someone help me please?
Thanks
I would need more information in order to help you, but in essence; you are probably looking for a file in a path that doesn’t exist. If your environment variable isn’t setup for: %STUDIO_SDK_PATH%
, then the path wont work properly.
Instead of %STUDIO_SDK_PATH%
, try to enter the full path in the line to the sdkmanager.bat.
Basically what I’m doing is following this documentation:
on the point 3.9 says to edit the setupandroid.bat file with this SDKMANAGERPATH="$STUDIO_SDK_PATH/cmdline-tools/8.0/bin"
but after I done that, every time I try to open up the file, it opens and immediately closes again like it loads but closes without doing anything…
Did you run the .bat as an administrator?
Yes I tried that as well.
So this is my SetupAndroid.bat script:
@echo off
setlocal ENABLEEXTENSIONS
setlocal ENABLEDELAYEDEXPANSION
set KEY_NAME=HKLM\SOFTWARE\Android Studio
set VALUE_NAME=Path
set STUDIO_PATH=
IF “%5” == “-noninteractive” (
set PAUSE=
) ELSE (
set PAUSE=pause
)
SET PLATFORMS_VERSION=%1
SET BUILDTOOLS_VERSION=%2
SET CMAKE_VERSION=%3
SET NDK_VERSION=%4
rem hardcoded versions for compatibility with non-Turnkey manual running
if “%PLATFORMS_VERSION%” == “” SET PLATFORMS_VERSION=android-30
if “%BUILDTOOLS_VERSION%” == “” SET BUILDTOOLS_VERSION=30.0.3
if “%CMAKE_VERSION%” == “” SET CMAKE_VERSION=3.10.2.4988404
if “%NDK_VERSION%” == “” SET NDK_VERSION=21.4.7075529
FOR /F “tokens=2*” %%A IN (‘dir /b /s “C:\Users\USER\AppData\Local\Android\Sdk” ^| findstr “studio64.exe”’) DO (set STUDIO_PATH=%%B)
IF EXIST “%STUDIO_PATH%” (
echo.
) ELSE (
echo Android Studio not installed, please download Android Studio 3.5.3 from Download Android Studio & App Tools - Android Developers
%PAUSE%
exit /b 1
)
echo Android Studio Path: %STUDIO_PATH%
set VALUE_NAME=SdkPath
set STUDIO_SDK_PATH=
FOR /F “tokens=2*” %%A IN (‘dir /b /s “C:\Users\USER\AppData\Local\Android\Sdk” ^| findstr “studio64.exe”’) DO (set STUDIO_SDK_PATH=%%B)
set ANDROID_LOCAL=%LOCALAPPDATA%\Android\Sdk
if “%STUDIO_SDK_PATH%” == “” (
IF EXIST “%ANDROID_LOCAL%” (
set STUDIO_SDK_PATH=%ANDROID_LOCAL%
) ELSE (
IF EXIST “%ANDROID_HOME%” (
set STUDIO_SDK_PATH=%ANDROID_HOME%
) ELSE (
echo Unable to locate local Android SDK location. Did you run Android Studio after installing?
%PAUSE%
exit /b 2
)
)
)
echo Android Studio SDK Path: %STUDIO_SDK_PATH%
if DEFINED ANDROID_HOME (set a=1) ELSE (
set ANDROID_HOME=%STUDIO_SDK_PATH%
setx ANDROID_HOME “%STUDIO_SDK_PATH%”
)
if DEFINED JAVA_HOME (set a=1) ELSE (
set JAVA_HOME=%STUDIO_PATH%\jre
setx JAVA_HOME “%STUDIO_PATH%\jre”
)
set NDKINSTALLPATH=%STUDIO_SDK_PATH%\ndk%NDK_VERSION%
set PLATFORMTOOLS=%STUDIO_SDK_PATH%\platform-tools;%STUDIO_SDK_PATH%\tools
set KEY_NAME=HKCU\Environment
set VALUE_NAME=Path
set USERPATH=
FOR /F “tokens=2*” %%A IN (‘REG.exe query “%KEY_NAME%” /v “%VALUE_NAME%”’) DO (set USERPATH=“%%B”)
where.exe /Q adb.exe
IF /I “%ERRORLEVEL%” NEQ “0” (
echo Current user path: %USERPATH%
setx PATH “%USERPATH%;%PLATFORMTOOLS%”
echo Added %PLATFORMTOOLS% to path
)
set SDKMANAGER=C:\Users\USER\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\sdkmanager
IF EXIST “%SDKMANAGER%” (
echo Using sdkmanager: %SDKMANAGER%
) ELSE (
set SDKMANAGER=C:\Users\USER\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\sdkmanager
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
)
)
call “%SDKMANAGER%” “platform-tools” “platforms;%PLATFORMS_VERSION%” “build-tools;%BUILDTOOLS_VERSION%” “cmake;%CMAKE_VERSION%” “ndk;%NDK_VERSION%”
IF /I “%ERRORLEVEL%” NEQ “0” (
echo Update failed. Please check the Android Studio install.
%PAUSE%
exit /b 4
)
if EXIST “%NDKINSTALLPATH%” (
echo Success!
setx NDKROOT “%NDKINSTALLPATH%”
setx NDK_ROOT “%NDKINSTALLPATH%”
) ELSE (
echo Update failed. Did you accept the license agreement?
%PAUSE%
exit /b 5
)
%PAUSE%
exit /b 0
Now the message that I receive is the following:
Have you installed Android Studio, and if so; where?
The actual Android Studio app? in this location: “C:\Program Files\Android\Android Studio\bin”
This is the same path as mine: C:\Program Files\Android\Android Studio.
Looking at my .bat file compared to yours, I have this line which is different from yours:
Line 25, it is also repeated again later down in the file:
FOR /F "tokens=2*" %%A IN ('REG.exe query "%KEY_NAME%" /v "%VALUE_NAME%"') DO (set STUDIO_PATH=%%B)
Thank you. it does work now. Had to change that line and had to download a .NET framework and now is working!
Awesome! Glad I could help!