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

**URL:** <https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323>\
**Category:** Mobile\
**Tags:** unreal-engine, UE4-26, question\
**Created:** [December 30, 2021, 11:14pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323 "2021-12-30T23:14:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![J0hn-C0nn0r](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@J0hn-C0nn0r](https://forums.unrealengine.com/u/J0hn-C0nn0r)\
**Post date:** [December 30, 2021, 11:14pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/1 "2021-12-30T23:14:55Z")

</div>

I’m at a complete loss here, I’m trying to setup Android Development and have tried 4 different methods even followed the Unreal Engine guide but every time I run the SetupAndroid.bat to install the NDK I get this error

```auto
C:\Program Files\Epic Games\UE_4.26\Engine\Extras\Android>SetupAndroid.bat
Android Studio Path: C:\Program Files\Android\Android Studio
Android Studio SDK Path: C:\Users\depre\AppData\Local\Android\Sdk
\Microsoft was unexpected at this time.

```

If anyone could shed some light onto what’s going on I would appreciate it.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/e/6e9df244440ccbdc6499bcaf9a3f2dfebad440c6.png)

---

<div class="post-metadata">

**Author:** ![J0hn-C0nn0r](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@J0hn-C0nn0r](https://forums.unrealengine.com/u/J0hn-C0nn0r)\
**Post date:** [December 31, 2021, 2:30am UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/2 "2021-12-31T02:30:59Z")

</div>

I didn’t figure this out but I got it working without it anyway.

---

<div class="post-metadata">

**Author:** ![grinchfox](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/grinchfox/32/476769_2.png) [@grinchfox](https://forums.unrealengine.com/u/grinchfox)\
**Post date:** [April 15, 2022, 3:42pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/3 "2022-04-15T15:42:04Z")

</div>

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:

```auto
	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`):

```auto
setlocal EnableDelayedExpansion

```

and replace `%` with `!` on lines 67 and 68:

```auto
	IF EXIST "!SDKMANAGER!" (
		echo Using sdkmanager: !SDKMANAGER!

```

---

<div class="post-metadata">

**Author:** ![J0hn-C0nn0r](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@J0hn-C0nn0r](https://forums.unrealengine.com/u/J0hn-C0nn0r)\
**Post date:** [April 15, 2022, 4:23pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/4 "2022-04-15T16:23:47Z")

</div>

Thanks, I was running this on Windows 11 at the time. I’m not sure if it still has the same issue but I re-installed Windows 10 and it worked just fine. Thanks again for the response, If I come across this issue again I’ll be sure to give this a shot.

---

<div class="post-metadata">

**Author:** ![Starkium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/starkium/32/1194588_2.png) [@Starkium](https://forums.unrealengine.com/u/Starkium)\
**Post date:** [May 11, 2022, 10:02pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/5 "2022-05-11T22:02:58Z")

</div>

these are already set up like this in the .bat I have, why else might this be the issue

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/8/af88a385d49934798c29e562839971fa2c5a7dde.png)

---

<div class="post-metadata">

**Author:** ![hexicGrind](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hexicGrind](https://forums.unrealengine.com/u/hexicGrind)\
**Post date:** [June 27, 2022, 5:53pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/6 "2022-06-27T17:53:54Z")

</div>

Thank you so much. I wouldn’t have figured this out without you!

---

<div class="post-metadata">

**Author:** ![McNugget6750](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@McNugget6750](https://forums.unrealengine.com/u/McNugget6750)\
**Post date:** [August 30, 2022, 4:30pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/7 "2022-08-30T16:30:06Z")

</div>

did you ever figure this out? I just ran into the same issue

---

<div class="post-metadata">

**Author:** ![Starkium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/starkium/32/1194588_2.png) [@Starkium](https://forums.unrealengine.com/u/Starkium)\
**Post date:** [August 30, 2022, 5:02pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/8 "2022-08-30T17:02:27Z")

</div>

you could try why this guy suggests here, video is in gernman so put on subs  
[Tutorial for Unreal Engine 5: Develop and install Virtual Reality App for the Oculus/Meta Quest (2) - Platform & Builds / XR Development - Unreal Engine Forums](https://forums.unrealengine.com/t/tutorial-for-unreal-engine-5-develop-and-install-virtual-reality-app-for-the-oculus-meta-quest-2/634637)

---

<div class="post-metadata">

**Author:** ![Zcience](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zcience/32/951950_2.png) [@Zcience](https://forums.unrealengine.com/u/Zcience)\
**Post date:** [January 12, 2023, 12:13pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/9 "2023-01-12T12:13:01Z")

</div>

Wrapping %USERPATH" in quotes on line 56 fixed the issue for me, thanks a bunch @grinchfox

---

<div class="post-metadata">

**Author:** ![c05](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c05](https://forums.unrealengine.com/u/c05)\
**Post date:** [February 7, 2024, 8:28pm UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/10 "2024-02-07T20:28:23Z")

</div>

This helped massively, thank you!

---

<div class="post-metadata">

**Author:** ![HAYTHAM\_KENWAY](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HAYTHAM\_KENWAY](https://forums.unrealengine.com/u/HAYTHAM_KENWAY)\
**Post date:** [June 30, 2024, 4:42am UTC](https://forums.unrealengine.com/t/android-setupandroid-bat-keeps-giving-this-error-was-unexpected-at-this-time-ue-4-26/269323/11 "2024-06-30T04:42:45Z")

</div>

Thank you so much
