# Why is SetupAndroid.bat failing with default setup directories?

**URL:** <https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313>\
**Category:** Mobile\
**Tags:** unreal-engine, UE4-25, setup, Android, UE4, question\
**Created:** [June 6, 2020, 4:42pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313 "2020-06-06T16:42:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mike\_patterson](https://forums.unrealengine.com/u/mike_patterson)\
**Post date:** [June 6, 2020, 4:42pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/1 "2020-06-06T16:42:38Z")

</div>

# Steps to Repro:

1. Open Epic Games Launcher on Windows
2. Uninstall any existing copies of Unreal Engine
3. Download and Install Engine version 4.25.1
4. Launch 4.25.1 to ensure installation is correct
5. Shutdown both the Engine and the Epic Games Launcher application
6. Follow all steps exactly in [Setting Up Android SDK and NDK for Unreal | Unreal Engine Documentation][1] using default installation locations, making sure to download Android Studio 3.5.3 (_android-studio-ide-191.6010548-windows.exe_)

# Expected Results:

Running the **SetupAndroid.bat** script in Step 3.3 results in being prompted to accept the Android SDK license agreement.

# Actual Results:

 ![303675-ue4-25-setupandroid.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/7/5/c75d0627286e50ecdc4ccdfc298fd02b99df8576.png)

# Context

After uninstalling 4.24 and installing 4.25, I pulled up the [Setting Up Android SDK and NDK for Unreal | Unreal Engine Documentation][3] page so I could be certain that my android environment was set up for the new engine. I’ve followed the instructions here to a T, including the recommendations to completely uninstall CodeWorks and any NDK components. CodeWorks was installed at its default location, and I have made sure the completely delete the **C:\NVPACK** folder.

I followed the rest of the instructions on the documentation page to a T as well. I made sure to download Android Studio 3.5.3 specifically, the exe file downloaded was as listed in the documentation screenshot:

_android-studio-ide-191.6010548-windows.exe_.

Following the setup instructions to the letter, installing only at default installation directories, I have come across a total blocker at Step 3.3:

 ![303676-ue4-25-settingupunrealtouseandroidndk.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/0/a/e0a15331ffffe8e8dac4ce68263b39129c12cfc1.png)

The script is supposed to prompt me to accept a license agreement, but instead the script outputs the following (I’ve replaced my username with `<USERFOLDER>`:

```
C:\Program Files\Epic Games\UE_4.25\Engine\Extras\Android>SetupAndroid.bat
Android Studio Path: "C:\Program Files\Android\Android Studio"
Android Studio SDK Path: C:\Users\<USERFOLDER>\AppData\Local\Android\Sdk
\Android\android-sdk\platform-tools was unexpected at this time.

```

And that’s it, the script doesn’t run beyond that. Any help in getting me past this in my Unreal Android Setup would be greatly appreciated, thanks for reading! 🙂

---

<div class="post-metadata">

**Author:** ![mike\_patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mike\_patterson](https://forums.unrealengine.com/u/mike_patterson)\
**Post date:** [June 14, 2020, 11:12pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/2 "2020-06-14T23:12:23Z")

</div>

Well, I figured out by dropping in “echo” statements all over the SetupAndroid.bat file that my error is occuring somewhere around Line 55 in the Batch script.

 ![304420-ue-4-25-1-batcherror.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/a/3aa6b18ecb8bd2c9a39cdd2ebdcd45a20ecd28f6.png)

If I alter the script by adding `echo %ERRORLEVEL%` both before and after the line `where.exe /Q adb.exe`, command prompt should print out the value stored there both times. As you’ll see in the command prompt screenshot, %ERRORLEVEL% returns both 0 and then it returns 1. So it follows then, that the next conditional statement `IF "%ERRORLEVEL%" NEQ "0"` should return true since %ERRORLEVEL% is indeed not 0, it’s 1, _ **but neither of the code blocks whether true or false execute the code within them.** _

 ![304431-ue-4-25-1-batchedit.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/d/3/ad3e44caa26c7026fa98c0c9dc8b2d4a9e49e830.png)

![304432-ue-4-25-1-batcheditoutput.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/3/dc380a0ddd6dae5778fd9b9480c93f771d3bd1f6.png)

So with this altered batch file, I’d expect the command prompt to read “ERRORLEVEL is indeed NOT zero” since we just checked the value of %ERRORLEVEL% and you can see the 0 and 1 in the above screenshot. I think it’s very weird that it is _here_ of all places that the script seems to fail, outputting instead `\Android\android-sdk\platform-tools was unexpected at this time.`

You can clearly see that my two `echo %ERRORLEVEL%` statements are working correctly. I just don’t really understand why the following conditional statement is failing, especially after commenting out the original statements and just trying to print some string values.

I guess I’m going to give up on this and manually download NDK and manually target the SDK, NDK, and JDK directories. Would still appreciate any help from anyone who might have a clue as to what’s going on here.

---

<div class="post-metadata">

**Author:** ![smudgy67](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smudgy67/32/1194584_2.png) [@smudgy67](https://forums.unrealengine.com/u/smudgy67)\
**Post date:** [June 20, 2020, 6:00pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/3 "2020-06-20T18:00:46Z")

</div>

Hey there,

Did you manage to suss this?  
I try and run the batch file and it closes immediately after it’s run.  
Please could you tell me what JDK version you have, I had to download mine from Oracle, which is V14. Maybe this is not the right version to go with Android Studio 3.5.3.

Must admit this all seems quite complicated on Epic’s and Androids behalf.

All the best and stay safe =]

---

<div class="post-metadata">

**Author:** ![mike\_patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mike\_patterson](https://forums.unrealengine.com/u/mike_patterson)\
**Post date:** [June 20, 2020, 9:58pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/4 "2020-06-20T21:58:45Z")

</div>

Nope, I have **not** been able to figure this out, and it is still very much a mystery to me. I haven’t downloaded JDK manually yet because I don’t know what’s compatible with Android Studio 3.5.3, and I don’t really know where to look for that info, especially in regards to how it relates to UE4.25.

Best of luck friend, please let me know how it goes. I hope other people can come across this thread too, I was certain no one would see it at all 🙂

---

<div class="post-metadata">

**Author:** ![smudgy67](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smudgy67/32/1194584_2.png) [@smudgy67](https://forums.unrealengine.com/u/smudgy67)\
**Post date:** [June 21, 2020, 1:43pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/5 "2020-06-21T13:43:28Z")

</div>

That’s a shame, Dude, don’t understand why these things are so complicated.

Found the JDK on Oracles site, though there’s videos out stating you don’t need it as it’s already embedded in AS3.5.3, the version I got was Oracle, JDK14, think this is way too high and should be JDK8.  
Though, as always, there’s so much conflicting information available.

Ok, back on the trail, and removed everything pertaining to Android Studio and NVIDIA Codeworks.  
Check out your Environmental Variables and delete all entries relating to Android prior to reinstalling AS.

Will keep you posted, let me know if you have any further luck too, please?

All the best and stay safe =]

EPIC:  
If you come across this issue, then please help the both of us out; Thank you in hope!?!

---

<div class="post-metadata">

**Author:** ![smudgy67](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smudgy67/32/1194584_2.png) [@smudgy67](https://forums.unrealengine.com/u/smudgy67)\
**Post date:** [June 21, 2020, 1:46pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/6 "2020-06-21T13:46:26Z")

</div>

Please see:  
[How to completely uninstall Android Studio from windows(v10)? - Stack Overflow](https://stackoverflow.com/questions/39953495/how-to-completely-uninstall-android-studio-from-windowsv10#:~:text=Step%201%3A%20Run%20the%20Android,versions%2C%20uninstall%20them%20as%20well).

---

<div class="post-metadata">

**Author:** ![smudgy67](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smudgy67/32/1194584_2.png) [@smudgy67](https://forums.unrealengine.com/u/smudgy67)\
**Post date:** [June 21, 2020, 2:08pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/7 "2020-06-21T14:08:25Z")

</div>

Also under Project Settings\>Platforms - Android SDK: SDKConfig, reset the location of the file paths to blank for SDK, NDK & JDK.

With all this in mind, I’ll try and establish the correct JDK, though as mentioned before in a post and video this is not required.

In addition, all the videos I’ve seen, state what Epic say in their docs, however, there SetupAndroid.bat file always works, this has never upto now anyway worked for me, so cross fingers, here I go again, lol.

---

<div class="post-metadata">

**Author:** ![smudgy67](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smudgy67/32/1194584_2.png) [@smudgy67](https://forums.unrealengine.com/u/smudgy67)\
**Post date:** [June 22, 2020, 9:20am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/8 "2020-06-22T09:20:11Z")

</div>

Hey Mike,

Ok, got this sussed yesterday and now have app on Samsung S8.

This is what I did…

1. Remove everything pertaining to Android Studio and NVIDIA Codeworks. Check out your Environmental Variables and delete all entries relating to Android prior to reinstalling AS.  
Also follow this helpful link on Android Studio removal:  
[How to completely uninstall Android Studio from windows(v10)? - Stack Overflow](https://stackoverflow.com/questions/39953495/how-to-completely-uninstall-android-studio-from-windowsv10#:~:text=Step%201%3A%20Run%20the%20Android,versions%2C%20uninstall%20them%20as%20well).

2. Follow this really helpful video upto the point of running the dreaded and anti climatic SetupAndroid.bat file.  
[UNREAL ENGINE 4.25.1 PACKAGING FOR ANDROID TUTORIAL UPDATED! - YouTube](https://www.youtube.com/watch?v=4SY2Za6j7UY&feature=youtu.be)

In addition, when you open up a UE4 project file, go to Project Settings\>Platforms - Android SDK: SDKConfig, reset the location of the file paths to blank for SDK, NDK & JDK.  
N.B. My install of Android Studio was slightly different to the video, it ask me for Intel x86 Emulator Accelerator (HAXM installer) and Android Emulator; I checked these too.

1. Try to run the bat file, though I should think it’ll still flash up briefly, which again is more than annoying.

2. Open Android Studio\>File\>Settings\>Appearance & Behaviour\>System Settings\>Android SDK and select the SDK Tools tab.  
Uncheck, Hide Obselete Packages and check, Show Package Details (Bottom right on page).  
Check, NDK (Side by side)\>21.1.6352462, and check, CMake\>3.10.2.4988404  
Hit apply, then, ok, and exit AS.

3. Check Environmental Variables are like the screenshot in relation to any Android as shown:

 ![305115-enviromental-variables.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/8/a38b769cdf3e7be6121494e5ed5950a8dd769d82.png)

1. At this point you may want to check your Registry entries and ensure for Computer\HKEY\_LOCAL\_MACHINE\SOFTWARE\Android Studio, that the Path and SdkPath are correctly set to Drive:\Users\username\Documents\AndroidStudio and Drive:\Users\username\Documents\ANDROIDSDK respectively.

2. Now for the fun bit, back to UE4.25, open your Project and access Project Settings, type sdk in search window.  
Under Platforms - Android, accept SDK License.  
Under Platforms - Android SDK:  
Location of Android SDK\> Drive:/Username/Documents/ANDROIDSDK  
Location of Android NDK\> Drive:/Username/Documents/ANDROIDSDK/ndk/21.1.6352462  
Location of JAVA\> Drive:/Username/Documents/AndroidStudio/jre

3. Build your UE4.25 Android project, and run the, Install\_PodgerAndroid425\_0-armv7.bat, file in the Build folder under your Project folder.  
Fingers crossed this will work for you?! Please, let me know how you get on.

All the best and stay safe =]

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ce2be74a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ce2be74a](https://forums.unrealengine.com/u/anonymous_user_ce2be74a)\
**Post date:** [June 25, 2020, 12:36am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/9 "2020-06-25T00:36:14Z")

</div>

Hey there!

I’m having the same exact issue.

Seems like its a bug with the recent 4.25.1 hotfix because everywhere I look, people with 4.25 are doing this succesfully.

Please update if you manage to find a convenient fix!

---

<div class="post-metadata">

**Author:** ![smudgy67](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/smudgy67/32/1194584_2.png) [@smudgy67](https://forums.unrealengine.com/u/smudgy67)\
**Post date:** [June 25, 2020, 12:53am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/10 "2020-06-25T00:53:37Z")

</div>

Hey patchmw,

I had real issues with it, but I found the solution below, did you follow the steps?

---

<div class="post-metadata">

**Author:** ![yarsento](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yarsento](https://forums.unrealengine.com/u/yarsento)\
**Post date:** [July 11, 2020, 8:45pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/11 "2020-07-11T20:45:55Z")

</div>

I had the same issue, for me the problem was the line 57 of SetupAndroid.bat: `setx PATH "%USERPATH%;%PLATFORMTOOLS%"`.  
I printed out USERPATH with echo and it was already a quoted string, so it results in a string that is partly double quoted.  
What fixed it for me was taking a substring of USERPATH with removed quotes at the beginning and the end:

`setx PATH "%USERPATH:~1,-1%;%PLATFORMTOOLS%"`

---

<div class="post-metadata">

**Author:** ![Unreolog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Unreolog](https://forums.unrealengine.com/u/Unreolog)\
**Post date:** [July 22, 2020, 10:51am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/12 "2020-07-22T10:51:03Z")

</div>

Thank you! Your advice helped me. You awesome

---

<div class="post-metadata">

**Author:** ![salimrached](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@salimrached](https://forums.unrealengine.com/u/salimrached)\
**Post date:** [July 22, 2020, 6:20pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/13 "2020-07-22T18:20:18Z")

</div>

Hey Guys, I struggled with this fro 2 days then I found this very useful video, It works like a charm Let’s all give him a thumbs up guys

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/c/4bc2ce75882b2f9d66e566bf97225f70941d8fff.jpeg "Installing Android Studio SDK & NDK For UE4 4.25") ](https://www.youtube.com/watch?v=q-mAEnqZb0M)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_21b98de6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_21b98de6](https://forums.unrealengine.com/u/anonymous_user_21b98de6)\
**Post date:** [July 28, 2020, 1:52pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/14 "2020-07-28T13:52:51Z")

</div>

Worked for me as well, you are awesome indeed

---

<div class="post-metadata">

**Author:** ![Punal100](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Punal100](https://forums.unrealengine.com/u/Punal100)\
**Post date:** [August 15, 2020, 4:49am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/15 "2020-08-15T04:49:00Z")

</div>

Thnaks This worked very well!

---

<div class="post-metadata">

**Author:** ![mike\_patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mike\_patterson](https://forums.unrealengine.com/u/mike_patterson)\
**Post date:** [September 7, 2020, 1:27am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/16 "2020-09-07T01:27:08Z")

</div>

Hey OP here, so what ended up working for me was this video posted by someone else responding to my forum thread 🙂

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/1/1/3119b40f7e66b36f960da7656a9ce469f23623e0.jpeg "UNREAL ENGINE 4.25.1 PACKAGING FOR ANDROID TUTORIAL UPDATED!") ](https://www.youtube.com/watch?v=4SY2Za6j7UY)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_93f06e21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_93f06e21](https://forums.unrealengine.com/u/anonymous_user_93f06e21)\
**Post date:** [September 27, 2020, 2:40am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/17 "2020-09-27T02:40:41Z")

</div>

Okay, all of this just boils down to poor programming on Epic’s part.

If you have any path with a space in it in your PATH variable, the script barfs.  
Thankfully I’ve modified the default path for most things, so it’s not an issue, you may have more or less luck.

The reason the videos above work is that they’re installing to a path with no spaces.

Essentially:

- Winkey + R
- “Environment Variables”
- “Environment Variables” button at the bottom right
- in “user variables for you” find PATH
- hit edit
- take a screenshot incase you need them back
- remove any path with a space in it ( c:\program files, c:\program files (x86), c:\whatever\my awesome stuff)

I’m brand new to the forums so could someone please tag a member of staff to get this fixed?  
Thanks.

Disappointed though.  
Just switched over from 8 years of Unity because I’m stick of this poorly tested, nonworking, divergent mess of a system. Head in the game please.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_93f06e21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_93f06e21](https://forums.unrealengine.com/u/anonymous_user_93f06e21)\
**Post date:** [September 27, 2020, 2:40am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/18 "2020-09-27T02:40:55Z")

</div>

Okay, all of this just boils down to poor programming on Epic’s part.

If you have any path with a space in it in your PATH variable, the script barfs.  
Thankfully I’ve modified the default path for most things, so it’s not an issue, you may have more or less luck.

The reason the videos above work is that they’re installing to a path with no spaces.

Essentially:

- Winkey + R
- “Environment Variables”
- “Environment Variables” button at the bottom right
- in “user variables for you” find PATH
- hit edit
- take a screenshot incase you need them back
- remove any path with a space in it ( c:\program files, c:\program files (x86), c:\whatever\my awesome stuff)

I’m brand new to the forums so could someone please tag a member of staff to get this fixed?  
Thanks.

Disappointed though.  
Just switched over from 8 years of Unity because I’m stick of this poorly tested, nonworking, divergent mess of a system. Head in the game please.

---

<div class="post-metadata">

**Author:** ![Noah\_Matsuyoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Noah\_Matsuyoshi](https://forums.unrealengine.com/u/Noah_Matsuyoshi)\
**Post date:** [October 13, 2020, 2:10am UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/19 "2020-10-13T02:10:11Z")

</div>

Thanks so much finally got it to work by doing this!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e62d6701](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e62d6701](https://forums.unrealengine.com/u/anonymous_user_1e62d6701)\
**Post date:** [February 4, 2021, 5:26pm UTC](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313/20 "2021-02-04T17:26:54Z")

</div>

In my case, this has to do with the directory “Program Files (x86)” being present in my path. I get the error “\Microsoft was unexpected at this time” Your path might contain this directory too if you are using a 64-bit version of Windows.

The crux of the issue is those parentheses around the “(x86)”, the batch file can’t handle it. I’ve attempted a fix but I’m not great at .bat syntax so I’ll let you know how it goes.

[Next page](https://forums.unrealengine.com/t/why-is-setupandroid-bat-failing-with-default-setup-directories/466313.md?page=2)
