简体   繁体   中英

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?

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

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

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.

Unity 2020.3.38f1 A empty project in unity take 6 mb size in ARMv7 and take 12mb size in both ARMv7and ARM 64 during building the apk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM