# Launch with Command Line Argument on Android

**URL:** <https://forums.unrealengine.com/t/launch-with-command-line-argument-on-android/136158>\
**Category:** Mobile\
**Tags:** unreal-engine, Android\
**Created:** [January 9, 2020, 4:02am UTC](https://forums.unrealengine.com/t/launch-with-command-line-argument-on-android/136158 "2020-01-09T04:02:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@patrickreece](https://forums.unrealengine.com/u/patrickreece)\
**Post date:** [January 9, 2020, 4:02am UTC](https://forums.unrealengine.com/t/launch-with-command-line-argument-on-android/136158/1 "2020-01-09T04:02:10Z")

</div>

Hi,

I am trying to launch my game on Android with some command line arguments. Specifically I would like to use either of the trace options in the Insights documentation. I cannot find any way to set command line arguments, either via Launch in editor, or packaging and installing a build using a bat file.

I have tried

- modifying the UE4CommandLine.txt, and putting it in my game folder on the android device
- modifying the UE4CommandLine.txt, and putting it in /mnt/sdcard/UE4Game/UE4Game/UE4CommandLine.txt, as with PushCommandLine.bat
- using the editor preferences’ additional launch parameters for mobile

The game runs fine, but none of the command line arguments seem to be applied.  
Any ideas? Thank you!  
Patrick

---

<div class="post-metadata">

**Author:** ![patrickreece](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@patrickreece](https://forums.unrealengine.com/u/patrickreece)\
**Post date:** [January 13, 2020, 6:21am UTC](https://forums.unrealengine.com/t/launch-with-command-line-argument-on-android/136158/2 "2020-01-13T06:21:02Z")

</div>

Ok, I fixed the problem by upgrading to UE 4.24, and making sure to modify the existing UE4CommandLine in the device’s game folder. I can now create a tracefile, then copy it to my computer to view it in Insights.

For packaged builds, I run these commands in a bat file to run the game on Android:  
%ANDROID\_HOME%\platform-tools\adb.exe push UE4CommandLine.txt /mnt/sdcard/UE4Game/PROJECTNAME/UE4CommandLine.txt  
%ANDROID\_HOME%\platform-tools\adb.exe shell am start -n com.COMPANYNAME.EXENAME/com.epicgames.ue4.SplashActivity

I also found out you can run console commands via adb, such as: **adb shell am broadcast -a android.intent.action.RUN -e cmd 'stat sceneRendering’**

---

<div class="post-metadata">

**Author:** ![Vuthric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vuthric](https://forums.unrealengine.com/u/Vuthric)\
**Post date:** [June 26, 2020, 6:10pm UTC](https://forums.unrealengine.com/t/launch-with-command-line-argument-on-android/136158/3 "2020-06-26T18:10:52Z")

</div>

This is very helpful. Thank you

---

<div class="post-metadata">

**Author:** ![ja0335](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ja0335/32/560997_2.png) [@ja0335](https://forums.unrealengine.com/u/ja0335)\
**Post date:** [September 9, 2022, 7:47pm UTC](https://forums.unrealengine.com/t/launch-with-command-line-argument-on-android/136158/4 "2022-09-09T19:47:07Z")

</div>

For UE5 in case anyone needs.

1. Build your game in Development.
2. Open the Android Studio project as indicated here [Debugging Android Projects](https://docs.unrealengine.com/5.0/en-US/debugging-unreal-engine-projects-for-android-using-android-studio/)
3. Open the file under app \> assets \> UECommandLine.txt
4. You will see it contains something like …/…/…/YourGameName/YourGameName.uproject. Add the following so it looks like:

```auto
../../../YourGameName/YourGameName.uproject -tracefile=/storage/emulated/0/Android/data/com.YourCompanyName.YourGameName/files/UnrealGame/YourGameName/YourGameName/Saved/My_Trace.utrace -trace=counters,cpu,frame,bookmark,file,loadtime,gpu,rhicommands,rendercommands,object -statnamedevents

```

1. Save the file and execute the game again as indicated in [Debugging Android Projects](https://docs.unrealengine.com/5.0/en-US/debugging-unreal-engine-projects-for-android-using-android-studio/)
2. The last step will install the game to your connected Android device with the modiffied UECommandLine.txt
3. Just play your game to gatter the stats info you need and then exit the game
4. Pull the traced file to your pc using

```auto
adb.exe pull /storage/emulated/0/Android/data/com.YourCompanyName.YourGameName/files/UnrealGame/YourGameName/YourGameName/Saved/My_Trace.utrace "C:\My_Trace.utrace"

```

NOTE: if you can not find the trace file in the path:

```auto
/storage/emulated/0/Android/data/com.YourCompanyName.YourGameName/files/UnrealGame/YourGameName/YourGameName/Saved/.

```

I’ll sugest you to use FAndroidMisc::GamePersistentDownloadDir() to find out what is a valid location to use for your trace to be written.  
I added the following in my GameMode Tick function, then I built the game and ran it so I can see in the screen the debug msg with the path.

```auto
void MyGameMode::Tick(float DeltaTime)
{
        Super::Tick(DeltaTime);
#if PLATFORM_ANDROID
	UKismetSystemLibrary::PrintString(this, FString::Printf(TEXT("Write directory: %s"), FAndroidMisc::GamePersistentDownloadDir()));
#endif //PLATFORM_ANDROID
}

```
