Search
  • Kyle

How to Reduce your Android release App size, up to 47% or even more - React Native



After finished developing and building your app, you then realise that it is somewhat bigger than what you prefer. The first thought that comes to your mind is "how can this be reduced?" Consider using Hermes to achieve this. In one of our apps, we experienced about 19.2 percent decrease in app size when building release with Hermes. See the image below. Without Hermes


With Hermes


Also checkout another app where about 47% decrease in app size was experienced using Hermes.



How do we build with Hermes? You only need to edit one or two files.


In android/app/build.gradle enable Hermes

 project.ext.react = [     
    entryFile: "index.js",          
    enableHermes: true  // clean and rebuild if changing 
 ]


Also, if you're using ProGuard, you will need to add this rule in proguard-rules.pro :

-keep class com.facebook.hermes.unicode.** { *; }

Next, if you've already built your app at least once, clean the build:

$ cd android && ./gradlew clean

And now you can build ur release as you would normally do with

./gradlew bundleRelease

Also note that There are other benefits to using hermes like stated here: Hermes is an open-source JavaScript engine optimized for running React Native apps on Android. For many apps, enabling Hermes will result in improved start-up time, decreased memory usage, and smaller app size.

Also, ensure you're using at least version 0.60.4 of React Native.

7 views0 comments