# SetupAndroid.bat closes immediately after running it

**URL:** <https://forums.unrealengine.com/t/setupandroid-bat-closes-immediately-after-running-it/475940>\
**Category:** Mobile\
**Tags:** unreal-engine, Android, question\
**Created:** [December 16, 2020, 12:00am UTC](https://forums.unrealengine.com/t/setupandroid-bat-closes-immediately-after-running-it/475940 "2020-12-16T00:00:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_b3b07be51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b3b07be51](https://forums.unrealengine.com/u/anonymous_user_b3b07be51)\
**Post date:** [December 16, 2020, 12:00am UTC](https://forums.unrealengine.com/t/setupandroid-bat-closes-immediately-after-running-it/475940/1 "2020-12-16T00:00:34Z")

</div>

I tried also with UE 4.25 version. I followed the guide step-by-step and it doesn’t work. I red on the internet some issues related to SetupAndroid.bat so I folloed this ( [UNREAL ENGINE 4.25.1 PACKAGING FOR ANDROID TUTORIAL UPDATED! - YouTube](https://www.youtube.com/watch?v=4SY2Za6j7UY) ) guide. It doesn’t work anyways. I try to start the bat file but it closes immediately.

made a bat fine to read the output and here it is:

Android Studio Path:  
Android Studio SDK Path: C:\Users\Win10\AppData\Local\Android\Sdk

after that it crashes ☹

edit: I also manually tested the bat file and the problem occurs from this control

IF /I “%ERRORLEVEL%” NEQ “0” (  
echo Current user path: %USERPATH%  
setx PATH “%USERPATH%;%PLATFORMTOOLS%”  
echo Added %PLATFORMTOOLS% to path  
)

---

<div class="post-metadata">

**Author:** ![PW\_Dev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PW\_Dev](https://forums.unrealengine.com/u/PW_Dev)\
**Post date:** [February 10, 2021, 1:24am UTC](https://forums.unrealengine.com/t/setupandroid-bat-closes-immediately-after-running-it/475940/2 "2021-02-10T01:24:41Z")

</div>

That SetupAndroid.bat file is trash; the same thing happened to me. I had to manually install the ndk through Android Studio: Configure\>SDK Manager\>SDK Tools (tab)\>Show Package Details (check box)\>Scroll down and install NDK version 21.1.6352462. After that, restart your PC and pick up that vid at the 13 min mark.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a9213d52](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a9213d52](https://forums.unrealengine.com/u/anonymous_user_a9213d52)\
**Post date:** [February 14, 2021, 11:12pm UTC](https://forums.unrealengine.com/t/setupandroid-bat-closes-immediately-after-running-it/475940/3 "2021-02-14T23:12:07Z")

</div>

Same. It does not crash, but it does not load what it needs to for me to type yes in to cmd prompt. Tried above, installing ndk through android studio, still not working.

---

<div class="post-metadata">

**Author:** ![AnderGraw](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AnderGraw](https://forums.unrealengine.com/u/AnderGraw)\
**Post date:** [July 21, 2021, 4:27pm UTC](https://forums.unrealengine.com/t/setupandroid-bat-closes-immediately-after-running-it/475940/4 "2021-07-21T16:27:53Z")

</div>

There is an answer in [this thread](https://answers.unrealengine.com/questions/963972/why-is-setupandroidbat-failing-with-default-setup.html) by @alexandoise that solved my problem (which sounded very similar to yours). The error is caused by parentheses and spaces in your %PATH%. Include usebackq in your script:

```
FOR /F "tokens=2* usebackq" %%A IN ('REG.exe query "%KEY_NAME%" /v "%VALUE_NAME%"') DO (set USERPATH=%%B)

```
