Reduce the apk file size when building applications with React Native

Tram Ho

Hi everyone, today I am sharing a simple way to reduce the application of apk files from ~ 20Mb to ~ 6Mb, when building apps with React Native.

In the root directory of RN (React Native), navigate to the file build.gradle:

In the build.gradle file, you change the value of the following 2 variables to false

enableSeparateBuildPerCPUArchitecture = false

enableProguardInReleaseBuilds= false

By default, after building the application with React Native, the apk file will be named app-release.apk, because build.gradle will combine all the x86 and x64 arm architectures created to form a single apk file. However, this will make the size of the apk file extremely large (x4 times for all architectures).

After that, we can choose apk file with smaller size to test the application or upload to Google Play

Reference article:

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo