SetupAndroid.bat UE4.26.2 Error

When I run the file: (SetupAndroid.bat) under Unreal Engine 4.26.2

I get the following Error:
\common was unexpected at this time

After hours of testing I found that the problem is caused by the following line:
echo Current user path: %USERPATH%

which is located in:

where.exe /Q adb.exe
IF /I "%ERRORLEVEL%" NEQ "0" (
	echo Current user path: %USERPATH%
	setx PATH "%USERPATH%;%PLATFORMTOOLS%"
	echo "Added %PLATFORMTOOLS% to path"
)

the solution is to enclose the echo message in double qoutes:
echo “Current user path: %USERPATH%”

it seems that Setx causes a problem when preceded by an echo which has a variable which expansion contains parenthesis.
for example if the path contains:
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler

I hope this saves somebody some time.

3 Likes

This worked for me. Thanks!

Many THANKS!

Worked for me! Thanks so much!

Worked here, too! On Unreal Engine 5.0.3 Release!!! I cannot believe this is still not fixed!

You just saved me at least an hour. Thank you.