Gamasutra is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
July 5, 2020
arrowPress Releases







If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 

Unity3D – Reducing the APK file size of your build for mobile device

by Damien FREMONT on 06/30/20 11:07:00 am

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

 

Keeping the file size of the built app to a minimum is important, especially for mobile devices or for app stores that impose a size limit.

 

Diapositive1.PNG

Note: this article was made using Unity 2019.1

Edit (2020): use App Bundle now. Your app will be splitted in small parts for download, it’s one package for all hardware plateformes …and Google will force you into it next year anyway.

Content

  1. Don’t expect too much from Unity
  2. Remove useless assets, models, script etc
  3. Remove the parts of the engine you aren’t using
  4. Use small size textures/images and compression
  5. If you have audio, Convert songs to ogg
  6. Enable IL2CPP native compilation
  7. Build two separate APK

1. Don’t expect too much from Unity

Half of that size is taken up by the Unity engine. You won’t be able to get it much smaller and later version of Unity are bigger !!!

But no matter what you do, I doubt you’ll get a completed game smaller than ~20mb. It’s just a downside of using a game engine that has lots of features you don’t use.

Example: in 7-Zip > Open your APK file, wait, sort by Size …’lib’ use 10 mo, ‘assets\bin\Data\Managed’ 6 mo (compressed) …so that’s 16 mo for the engine in your APK, (uncompressed to compressed size is not linear, bad with lib, good with assets)

Screen Shot 05-04-19 at 01.18 PM.PNG

2. Remove useless assets, models, script etc

It’s common sense, but it’s easy to forget some large picture or sound files in your project.

Remove any stuff you don’t need, such as scenes that are in your build but not used.

Example: in WinDirStat > menu:File > Open Folder > choose your unity3d project > Ok, Wait, Navigate to Assets folder, Check your files …maybe there are some you don’t use or need.

Screen Shot 05-04-19 at 12.48 PM.PNG

Example: in Unity3D > menu: Window > General > Console), click the small drop-down panel in the top right, and select Open Editor Log …you’ll see only your files in uncompressed size, so it won’t be true in your APK !!! (uncompressed to compressed size is not linear, bad with DLL, good with picture file)

Screen Shot 05-04-19 at 01.40 PM.PNG

3. Remove the parts of the engine you aren’t using

Remove the parts of the engine you arent using instead of including all of it. Like Physics, x86 Architecture, .NET 4.x.

Unity supports two .NET API compatibility levels.: .NET 4.x and .NET Standard 2.0. The .NET Standard 2.0 restricts you to a smaller subset of the .NET API, which can help keep size down.

Change the build to just ARM you don’t need x86. Also check out the stripping level.

Example: in Unity3D > Menu > Build Settings > (new window) > Player Settings > (new window) > Player > Settings > ARMv7:true, x86:false, API Compatibility Level: NET Standard 2.0

Screen Shot 05-04-19 at 01.35 PM.PNG

4. Use small size textures/images and compression

Try reducing the sizes of your assets. Use compression on images (and reduce their resolution), reduce the bitrate of any audio, especially music.

You can reduce the colour depth of images that don’t need transparency.

Example: in Photoshop > Menu > File > Save for web > PNG 8, Image Size …File size is reduce from 600 ko to 40 ko !!!

Screen Shot 05-04-19 at 12.53 PM.PNG

5. If you have audio, Convert songs to ogg

Use a tool to convert sound files to .ogg format.

Example: http://www.the-converter.net/fr/audio > ogg, 16 KHz, 32 kb/s, mono

Screen Shot 05-04-19 at 03.55 PM.PNG

6. Enable IL2CPP native compilation

Install NDK and choose IL2CPP

Example: in Unity3D > Menu > Build Settings > (new window) > Player Settings > (new window) > Player > Settings > ‘Scripting Backend’:’IL2CPP’

Screen Shot 05-04-19 at 04.28 PM.PNG

7. Build two separate APK

Googleplay will impose ARM64. In the meantime, you’ll need to build for ARMv7 and ARM64. It’s only possible with IL2CPP activated.

But ARM64, like x86, adds about 5 MO to your APK file.

Example: in Unity3D > Menu > Build Settings > (new window) > Player Settings > (new window) > Player > Settings > ‘Split APK by Archi’:true

Screen Shot 05-04-19 at 04.30 PM.PNG

Resources

Reducing the file size of your build

How to reduce apk size?

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

How can we reduce apk file size in unity i made a game like flappy bird it is over 32 mb how to reduce the size .

Performance tips for Unity 2d mobile
 


This post was originally published on https://damienfremont.com/2019/05/04/unity3d-reducing-the-apk-file-size-of-your-build-for-mobile-device/

 


Related Jobs

innogames
innogames — Hamburg, Germany
[07.03.20]

PHP Game Developer - Grepolis
Remedy Entertainment
Remedy Entertainment — Espoo, Finland
[07.03.20]

Programmer (Character Technology team)
Square Enix Co., Ltd.
Square Enix Co., Ltd. — Tokyo, Japan
[07.03.20]

Experienced Game Developer
Remedy Entertainment
Remedy Entertainment — Helsinki, Finland
[07.01.20]

Technical Director





Loading Comments

loader image