Reducing APK Package Size

How to reduce the size of your packaged Android game.

Choose your operating system:

Windows

macOS

Linux

No matter what type of Android device your UE4 project is targeting, reducing the size of the Android application package ( APK ) to be under the 100 MB limit for the Google Play store can be challenging. In the following guide, we will cover steps you can take to help reduce your project's final APK package size to be as small as possible, using nothing but the tools provided to you in the UE4 Editor.

Legacy ETC1 Texture Considerations

If you are using an older version of Unreal Engine to package your project for Android using the ETC1 Texture format, you need to be aware that ETC1 will not compress Textures that have embedded Alpha information in them, and instead treat them as fully uncompressed Textures. While this will not greatly affect your project's run time performance, it will increase the size of your project's APK. If your project does require Textures that use Alphas, it is better to use two separate Textures; one for the Diffuse, and one for the Alpha, instead of a single Texture with the Alpha embedded inside of it. This will ensure that your Textures will be compressed when the project is cooked and packaged.

Platform-Agnostic Techniques

In addition to the Android-specific methods listed above, there are many ways to reduce the size of any packaged game (regardless of the target platform).

Creating a New Empty Project

When you first start working on your Android based mobile project, you might be tempted to use an existing project as a base to work from or create a new project that has the Starter Content enabled. Do not do this, instead, create an entirely new, empty C++ or Blueprint based project, and then use the

[Migration Tool](Basics/AssetsAndPackages/Migrate)
to bring over the content that you want to use. This way, you ensure that the only content in your project is content that needs to be there.

Compressing Cooked Content

The easiest and quickest way to reduce your APK package size is to tell UE4 to compress the APK packages during the packing process. To turn on package compression, you need to do the following in the UE4 Editor.

  1. First, open up the project's settings by going to the Main Toolbar and selecting the Edit option, then selecting Project Settings .

    T_Project_Settings_Menu.png

    T_Project_Settings_Menu_Mac.png

  2. Under the Project section, click on the Packaging section to show the options for how the project will be packaged.

    Click for full image.

  3. Click on the Advanced Properties that is at the bottom of the Packaging settings to expose the Advanced Project Settings .

    Click for full image.

  4. Look for the option labeled Create compressed cooked packages and enable it (if not already enabled).

    Click for full image.

If you have not packaged your game with the Create compressed cooked packages checkmark box enabled you should see a huge difference in size when your project is re-packaged with it enabled. In fact, it is not uncommon for some project's APK packages to be reduced in size by up to 50% when Create compressed cooked packages is enabled.

Shared Material Shaders & Libraries

Enabling both Share Material Shader Code and Share Material Native Libraries will help to reduce the overall package size of your project, but this comes at the cost of increased loading times. To enable this option in your UE4 project, you will need to do the following:

  1. First, on the Main Toolbar go to Edit > Project Settings .

    T_Project_Settings_Menu.png

    T_Project_Settings_Menu_Mac.png

  2. At the bottom of the Packing section, there will be the following two checkmark boxes that you should enable.

    • Share Material Shader Code

    • Share Material Native Libraries

    Click for full image.

Excluding Editor Content

Enabling this option will make sure that none of the content that the UE4 Editor uses will be packaged in your project. Note that enabling this could cause issues with missing content in projects that might make use of the Editor content. To enable these two options in your UE4 project, you will need to do the following:

  1. First, on the Main Toolbar go to Edit > Project Settings .

    T_Project_Settings_Menu.png

    T_Project_Settings_Menu_Mac.png

  2. Under the Project section, click on the Packaging section to show the options for how the project will be packaged.

    Click for full image.

  3. Click on the Advanced Properties that is at the bottom of the Packaging settings to expose the Advanced Project Settings .

    Click for full image.

  4. Scroll down until you see the Exclude editor content when cooking option and enable it by clicking on the checkmark box next to it.

    Click for full image.

    Enabling this may cause issues with missing content in projects that might make use of the Editor content.

Setting up a Project's Levels

One often overlooked area that can lead to the bloating of your projects APK package sizes is failing to correctly set up project's options, like which level should be used by default, or which level is used for level transitions. To set which level (or levels) should be used for this type of interaction, you can do the following.

  1. First, on the Main Toolbar go to Edit > Project Settings .

    T_Project_Settings_Menu.png

    T_Project_Settings_Menu_Mac.png

  2. Then, under Project in the Maps & Modes section look for the Default Maps section.

    Click for full image.

  3. Click the arrow next to Game Default Map , and from the Asset List , select the map that should be used for the game's default starting level.

    Click for full image.

  4. Repeat this process until you have level's input for each required map type.

Selecting which Content to Package or not Package

In the Packaging section of your project settings, you can specify which maps and content should or should not be packaged with your game. To specify which maps should be included in your project you will need to do the following:

If you do not specify which maps should be cooked then all maps will be cooked including any testing maps that you might have. Failing not to specify which maps should be cooked will result in your final packaged game being bigger than it needs to be.

  1. First, open up the project's settings by going to the Main Toolbar and selecting Edit > Project Settings .

    T_Project_Settings_Menu.png

    T_Project_Settings_Menu_Mac.png

  2. Then, under Project in the Packaging section look for the Packaging option.

    Click for full image.

  3. Click on the small white triangle at the bottom of the Packaging section to expose the advances packing options.

    Click for full image.

  4. Scroll to the lower part of the Advanced Packaging options till you see a checkmark box for Cook everything in the project content directory (ignore list of maps below) option. The options that you see here will allow you to specify which content and maps should be packaged or should not be packaged with your project.

    Click for full image.

  5. Press the white Plus Sign next to the option you want to use to include or exclude assets.

    Click for full image.

  6. Clicking on the three small white dots next to the new entry that was added will display a window that will allow you to pick which assets you want to include or exclude.

    Click for full image.

  7. When you have selected an asset, the entry box will now contain a link to where that asset is in your project's folder.

    Click for full image.

Property Name

Description

Cook everything in the project content directory (ignore list of maps below)

Cook all things in the project content directory.

Cook only maps (this only affects cook all)

Cook only maps (only affects the cook all flag).

Create compressed cooked packages

Create compressed cooked packages (decreased deployment size).

Do not include editor content in this package may cause game to crash/error if you are using this content

Skip cooking Editor content.

List of maps to include in a packaged build

List of maps to include when no other map list is specified on command line.

Additional Asset Directories to Cook

This lists additional directories containing .uasset files that should always be cooked regardless of whether they're referenced by anything in your project. Make sure to note that these paths are relative to your project Content directory.

Directories to never cook

This lists directories that should never be cooked.

Additional Non-Asset Directories to Package.

This list directories containing files that should always be added to the .PAK file (if using a .pak file; otherwise they're copied as individual files). This is used to stage additional file that you manually load via the UFS (Unreal File System) file IO API. Make sure to note that these paths are relative to your project Content directory.

Additional Non-Asset Directories to Copy.

This lists directories containing files that should always be copied when packaging your project, but are not supposed to be part of the .pak file. This is used to stage additional files that you manually load with using the UFS file IO API, ex, third-party libraries that perform their own internal file IO.

Make sure to note that these paths are relative to your project Content directory.

Checking what Content will be Cooked

To ensure that only the content that is related to your project is added to your APK file, you can check which content is being added to your project's APK by looking in the Cooked folder in your project. You can find the Cooked folder by going to (ProjectName)\Saved\Cooked and then choose the folder with the format you cooked your project for.

Please note that you will only be able to see the content in the Cooked folder after you complete your first cook.

Click for full image.

Click for full image.

The image below shows the Texture folder from the Match 3 sample game. The content in the folder has been sorted by size, so it is easier to see what assets are the biggest. Once the most significant assets have been determined, you can then examine the assets inside of UE4 to see if in fact they can be reduced in size without sacrificing the integrity of the asset.

Click for full image.

Click for full image.

Development Versus Shipping Build Size

When trying to figure out the final size your project will be, keep in mind that the Development version of your project will be slightly larger than your Shipping build size. On the Medieval Match example game, the difference in size between a Development and Shipping build was around 14 percent. However, since each project has different requirements, the saving between the two different build types for your project could be more or less than a 14 percent savings.

Per-Device Texture LOD's

With the release of Unreal Engine 4.8, you can now specify which size Texture should be used on which devices. You can read more about this in the Texture Guidelines for Mobile Platforms section.

Removing Unused Content

When your project is finally ready to be packaged up for the store, make sure to first remove any unused or testing content by selecting it in the Content Browser and deleting it. You can delete content by first selecting the content you want to delete and then either press the Delete key on the keyboard or use the Delete option in the context menu. When you do try and delete something from your project, the Delete Assets menu will be displayed like in the following image.

This is the preferred method of deleting objects in UE4 and should be used over just simply deleting/removing the assets from their location in the content folder.

DeleteAssets_Windows.png

Click for full image.

The Delete Assets menu will inform you if the asset you are trying to delete is referenced by another asset. If it is not referenced, you can simply delete it, however, if it is referenced by other assets, you can use the Replace References option to replace the reference to that asset to another asset that is supposed to be packaged in your project.

Removing Unused Plugins

Disabling any unused Plugins inside of the UE4 Editor is another way to ensure that unnecessary content and code do not make it into your project's final APK package file. This is because some Plugins require a particular set of base assets and code to work correctly. If the Plugin is not disabled, the assets and code that are needed to make the Plugin n work will not be removed from your project. While this might not reduce your project's size as much as reducing or removing a large Texture would, every little bit can help when trying to slim your project down to the 100 MB size. To disable a plug-in inside of UE4, you need to do the following:

Make sure you thoroughly test your project to ensure that the Plugins you are disabling do not interfere with the functionality of your project.

  1. First, open up the Plugins Manager by going to the Main Toolbar and clicking on the Window option and then selecting the Plugins option.

    T_Open_Plugins_Browser.png

    T_Open_Plugins_Browser_Mac.png

  2. From the Plugins Browser, select the different sections and disable any Plugins you are not using by un-checking the check mark box next to Enabled . When you have disabled all the Plugins , you will need to re-start the UE4 Editor and then make sure to re-package your project.

Package Black List

You can now place a text file in your project's Build/Platform/(Target Platform Folder) directory that will tell the cooker to exclude partial or complete file paths from being packaged into your project. Projects can have multiple Black List files for Debug, Development, Test, and Shipping builds that can be set up to include or exclude whatever project data you want. You can even have different Black List files for each platform your project supports like one for Android, one for iOS, etc. Here is an example of what the Black List files would look like for Match 3 on Android.

Click for full image.

Click for full image.

Here is an example from Match 3 where the cooker is told not to include the following files when the game is cooked and packaged.

  • Blacklist Text File Location & Name: Match3/Build/Android/ PakBlacklist-Shipping.txt :

    T_Black_List.png

    T_Black_List_Mac.png

The first three entries should be safe for any project, but there may be cases where the AssetRegistry.bin is needed at runtime (depending on your project). It is highly recommended that you thoroughly test to ensure that the content you are removing will not negatively impact your project. An easy and straightforward way to go about this is to open up all your project's levels to ensure that they correctly load and have no errors or warnings. If you run into further problems and are not sure where they are coming from, check the Logcat for errors.

Max Movable Spotlights / Point Lights

The property, Max Movable Spotlights / Point Lights can help reduce the number of shaders that are generated for dynamic lights. This feature is particularly useful for mobile games that do not require dynamic lighting and can be found in the Rendering section of Project Settings under Mobile Shader Permutation Reduction .

Click image for full view.

To completely disable this feature, set the Max Movable Spotlights / Point Lights setting from 4 to 0.

MobileShaderPermutation_0.png

Depending on the size of your project and the number of Materials used, the size savings you can achieve can range from just a few MB to the multiple MB ranges.

State

Packaged Game Size

Savings

ON

54.3 MB

0

OFF

53.2 MB

1.1 MB

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss