Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the size of an APK file in Unity?

Is the minimum APK size of an Android app made by Unity 8MB? I am building an empty project, but still getting 8MB. Is there a way to reduce the APK size?

like image 827
Bhupendra Kastore Avatar asked Jan 22 '15 23:01

Bhupendra Kastore


3 Answers

For reducing APK size:

In Unity 5.6.0f3 I have created a simple "Hello world" program and build an APK file, it consumes 21.2 MB at first but to reduce the size you have to follow these steps:


  1. Unity 5.6.0f3: Player settings > other settings > optimization > API compatibility level

    Unity 2018.3.6f1: Player Settings > Other Settings > Configuration > API Compatibility Level

    .NET 2.0 Subset.

    To avoid memory wastage, Unity also supports the .NET 2.0 Subset API profile. This is very similar to the Mono "MonoTouch" profile, so many limitations of the "MonoTouch" profile also apply to Unity's .NET 2.0 Subset profile.Unity's .NET 2.0 Subset profile.

  2. Unity 5.6.0f3: Player settings > other settings > device filter > ARMv7

    Unity 2018.3.6f1: Player Settings > Other Settings > Configuration > Target Architectures

    ARM and x86 are both processor architectures. x86 belongs to Intel while ARM is used by different companies and widely used, so no need to select both architectures.

  3. Unity 5.6.0f3: Player settings > other settings > rendering path > Legacy Vertex

  4. Unity 5.6.0f3: Player settings > other settings > Optimization > Stripping level > Use micro mscorlib

    The Lightweight mscorlib version will be used at expense of limited compatibility.

    Most games do not use all the functionality of the provided DLLs. With this option, you can strip out unused parts to reduce the size of the built player on Android devices.


After applying all these changes it becomes 10.4 MB.

For reducing IPA size:

In Xcode, there are few flags you need to set,

  • Build Settings-> Enable Objective-C Exception-Yes

  • Build Settings-> Enable BitCode-No

  • Build Settings-> Compress PNG files -No

like image 162
Abbas Kapasi Avatar answered Nov 17 '22 13:11

Abbas Kapasi


In Player settings, Device Filter, Select ARMv7 only
(In latest unity (2018.1), this can be found as Other Settings, Target Architecture)

Also scroll down, set Stripping level to Use Micro mscorlib

These should reduce the size a bit further

like image 42
Dinesh Rajan Avatar answered Nov 17 '22 13:11

Dinesh Rajan


Even though your project doesn't contain any of your code yet, it still contains the Unity libraries and they are a fixed size. 8MB is very small for any Android app, let alone a game. I wouldn't worry about that until later.

like image 30
Ansel Santosa Avatar answered Nov 17 '22 13:11

Ansel Santosa