Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce GMS size in apk

I'm trying to reduce the size of my instant apps apks. I managed to divide the main module into several smaller ones (features and libraries). Once the app is built, apk files are sized (with minify enabled): 4.9 MB (base feature), 5 MB (ui feature - activities, fragments, receivers etc) and 1.3MB (item details feature). The problem is that I don't know what else I can cut from modules, because the package that using the most of size is... com.google.android.gms.internal (screens below).

BaseFeature: enter image description here

UI Feature: ui feature

I'm afraid that even if I split those modules more, the problem with this library will still be there. I'm really close to finishing the instant app of my application, but I can't upload those files because of too large size. Can anyone knows how to figure out with this?

like image 844
Skye Avatar asked Nov 08 '22 17:11

Skye


1 Answers

Generally, here is what you can do to reduce APK size.

Methods that was in the scope of the documentation.

  1. Reduce resource count and size

    One of the simple ways to make your APK smaller is to reduce the number and size of the resources it contains. In particular, you can remove resources that your app no longer uses, and you can use scalable Drawable objects in place of image files.

    • Remove unused resources
    • Minimize resource use from libraries
    • Support only specific densities
    • Use drawable objects
    • Reuse resources
    • Render from code
    • Crunch PNG files
    • Compress PNG and JPEG files
    • Use WebP file format
    • Use vector graphics
    • Use vector graphics for animated images
  2. Reduce native and Java code

    • Remove unnecessary generated code
    • Avoid enumerations
    • Reduce the size of native binaries
    • Remove debug symbols
    • Avoid extracting native libraries
  3. Maintain multiple lean APKs

Your APK can contain content that users download but never use, like regional or language information. To create a minimal download for your users, you can segment your app into several APKs, differentiated by factors such as screen size or GPU texture support.

Another reference to Shrink Your Code and Resources

To make your APK file as small as possible, you should enable shrinking to remove unused code and resources in your release build. This page describes how to do that and how to specify what code and resources to keep or discard during the build.

like image 61
MαπμQμαπkγVπ.0 Avatar answered Nov 15 '22 07:11

MαπμQμαπkγVπ.0