Some digital distribution services have a limit on the initial install size of your application. Unity includes the following methods to help you to optimize the install size:
If your output application uses APK format, the Split APKs by target architecture Player setting optimizes the application download and installation size.
To split APKs by target architecture, follow these steps:
After you enable this setting, Unity creates a separate APK for each CPU architecture instead of producing one APK that contains binaries for every target CPU architecture selected in the Target Architectures Player Setting. You can upload this set of APKs to digital distribution services which serve the APK with the correct target CPU architecture to each device that downloads your application.
Google Play primarily supports this feature, which might not work for other digital distribution services. For more information, refer to Multiple APK support.
Note: Google Play requires new applications to be AABs and not APKs. When you upload an AAB, Google Play automatically generates and serves optimized APKs for each device configuration.
You can split your output application to make the initial install size smaller. The device can install a lighter version of your application and then download assets separately.
To split the application binary, follow these steps:
When enabled, Unity splits your application depending on its output format. For APK format, Unity creates a main APK and an expansion file (OBB). For more information, refer to APK expansion files. For AAB format, Unity creates a base module and asset packs. For more information, refer to Play Asset Delivery.
You can change the method Unity uses to compress resource files for the application.
To change the compression method, follow these steps:
Compression can reduce the size of the application but can increase loading times if decompressing the data takes longer.
You can use ProGuard minification to decrease the size of the application and improve performance.
To enable ProGuard minification, follow these steps:
Note: ProGuard might remove code that your application depends on. Test any builds you minify to verify that ProGuard didn’t remove critical functionality.
For more control over the minification process, generate a custom proguard.txt file and configure it to specify what not to strip. To generate the file, select Custom Proguard File in the Publishing Settings section. This generates the proguard.txt file in your project’s Assets/Plugins/Android folder. For information on how to configure ProGuard minification, refer to the ProGuard documentation.