Android "SetupAndroid.bat" keeps giving this error "was unexpected at this time." UE 4-26

This happens because you have bracket symbols in user paths and whoever wrote this batch script didn’t thought of that.

Can be fixed by editing SetupAndroid.bat and wrapping %USERPATH% in quotes on line 56:

	echo Current user path: "%USERPATH%"

Second problem you may encounter is SetupAndroid.bat unable to locate sdkmanager.bat even if it actually exists in <SDKPath>\cmdline-tools\latest\bin\sdkmanager.bat
In this case you need to add this line at the beginning (next line after after @echo off):

setlocal EnableDelayedExpansion

and replace % with ! on lines 67 and 68:

	IF EXIST "!SDKMANAGER!" (
		echo Using sdkmanager: !SDKMANAGER!
7 Likes