Reducing build size of Android or iOS game in Unreal Engine

Aug, 6 2021— #advanced

There are many ways to reduce the build size. After going through all the stages, I was able to reduce the size of the game on Android from 150 to 50 MB.

Build Configuration and For Distribution

The first you should set the "Build Configuration" to "Shipping" and enable "For distribution" as in the following screenshot:

Build Configuration -> Shipping.<br>For Distribution - On.

Build Configuration -> Shipping.
For Distribution - On.

Excluding and compresing assets

You should exclude unused assets and compress the needed ones in this way:

Create compressed cooked packages -> On.<br>Exclude editor content when cooking -> On.

Create compressed cooked packages -> On.
Exclude editor content when cooking -> On.

Use of sharing material

It is also useful to enable sharing material shader code and use of shared material native libraries, which will slightly reduce the size.

Share Material Shader Code -> On.<br>Shared Material Native Libraries -> On.

Share Material Shader Code -> On.
Shared Material Native Libraries -> On.

Disabling Movable Point Lights

If you are not using moving point lights, set "Max Movable Point Lights" to 0. This will slightly reduce the size of the shaders and hence the size of the assembly.

Max Movable Point Lights -> 0

Max Movable Point Lights -> 0

Removing unused packaged assets

You can also delete unnecessary assets that are packaged with your game but never used. First, you need to understand which assets you need to exclude during assembly. To do this, open the "main.obb.png" file as an archive located in the "assets" folder inside your game's pak file. To unpack the .pak file, open the console in the "Engine/Binaries/Win64" folder and write the following command:

UnrealPak.exe [PathToPakFile].pak -extract [PathToExtractPakFile]

After you have decided which assets and folders are not needed, you need to open (or create) the PakBlacklist-Shipping.txt file in the "[ProjectName]/Build/Android" folder, and specify the folders and files that need to be excluded when building the project. In my case, I got the following list (everyone will have their own):


Disabling engine modules

If you are sure that your game and all assets are as compressed as possible, but still not satisfied with the build size, there is another option - to rebuild the engine with disabling unnecessary but heavy modules that are also included when the project is packaged.

To do this, download the engine sources, generate the necessary files for Visual Studio and open the UE4.sln file.

Then open the file in Visual Studio and enter the following values (some parameters may not be relevant for your project, so use it if necessary):

bCompileAPEX = false;
bCompileICU = false;
bBuildDeveloperTools = true;
bCompileRecast = false;
bCompileSpeedTree = false;
bCompileForSize = true;
bCompileCEF3 = false;
bCompileFreeType = false;
bIWYU = true;
bUsesSlate = false;
bCompileChaos = false;
bUseChaos = false;
bUseChaosChecked = false;
bUseChaosMemoryTracking = false;
bCompilePhysX = false;
bCompileNvCloth = false;
bCompileRecast = false;
bCompileNavmeshSegmentLinks = false;
bCompileNavmeshClusterLinks = false;
bUseDebugLiveCodingConsole = false;
bUseLoggingInShipping = false;
bLoggingToMemoryEnabled = false;
bUseLauncherChecks = false;
bEnforceIWYU = true;

Then just rebuild the engine and that's all.

By Georgy Treshchev

Unreal Engine Developer. Contact for any questions. Telegram chat, e-mail, Github.