Reduce App size for Android in React native

Reduce App size for Android in React native

25 January 2021

Introduction

In today’s world, user’s like to have apps, which is not too large, particularly in markets where devices work on pay by byte usage plans, so it is nice to have an app which is small in size. There are many techniques provided by Android to fulfill this requirement. Today we are going to come across one of such techniques which will immediately reduce the app size.

Upload App with Android App Bundles

Android supports both 32-bit and 64-bit architecture. It is always nice to have an app which is released with resources and code that are needed for a particular device. A way we can achieve this is by creating an .aab file instead of .apk file and upload it to Google Playstore, which is then managed by Playstore itself to distribute to specific devices.

How to achieve this in React native?

Now you would be thinking, why we are only talking about Android as this blog should provide information regarding React native, so for the folks who are new in React native to let them know React native is hybrid framework which uses both Android and iOS platform as base with JS layer on the top, to simplify it, React native uses bridging technique to bridge native with JS. In order to generate .aab file in React native, run the following command in the root directory of the project:

$ cd android

$ ./gradlew bundleRelease

After successful generation of AAB(.aab), one can find it at the below location and check the difference in size when installed on the device:

android/app/build/outputs/bundle/release/app-release.aab

 Are there other techniques to Reduce app size?

Yes, there are other ways to reduce app size even after generating .aab file, which I will not cover in this blog, but you can refer to below link to get more information:

https://developer.android.com/topic/performance/reduce-apk-size

search
Blog Categories
Request a quote