How to reduce the size of an Android Android application

For my specific Android application, the size of the codes I wrote is only 12 KB

But the generated packet has a size of 7.9MB. How can I reduce this.

According to the documentation for the native answer, I already included proguard in the app_root/android/app/proguard-rules.pro , but app_root/android/app/proguard-rules.pro size

 ... android { ... buildTypes { release { ... minifyEnabled true } } } ... 

Is there a solution for this?

+6
source share
3 answers

React Native APK apps include JSCore binaries for x86 and ARM. If you do not need x86, you can reduce the size to 3-4 MB.

1) In your application /build.gradle is installed

 def enableSeparateBuildPerCPUArchitecture = true 

2) remove x86 from abiFilters

this helped me reduce the size from 7.8 mb to 4.5 mb.

+6
source

Android devices support two major device architectures: armebi and x86 . By default, RN compiles its own libraries for both of these architectures in the same apk file.

Open Android / app /build.gradle:

Set def enableProguardInReleaseBuilds = true ,

this would allow Progaurd to compress Java bytecode. This reduces the size of the application.

And,

Set def enableSeparateBuildPerCPUArchitecture = true .

And check in android / app / build / output / apk / - you will get two apk files for armebi and x86 with a size of about half the original apk.

+3
source

There are several ways to reduce the size of your APK:

  1. By dividing your application by architecture, you can split your APK into a list of well-known architectures: armeabi-v7a, x86, arm64-v8a, x86_64

    if you are distributing your application using the Play Store, it would be nice to do this using the Android application package.

  2. Enabling prodguard will reduce the size of the APK.

  3. Optimize your graphics resources, and if possible, try using SVG resources as often as possible.

There was a change in the size of the resulting APK in React-Native 0.62 due to the inclusion of a new JavaScript engine, which reduces the size of its own libraries by almost 40% HermesEngine

The statistics below are taken from the Hermes engine and also mention a decrease in APK size. enter image description here

+1
source

Source: https://habr.com/ru/post/1244882/


All Articles