A large APK size can slow down downloads, increase install drop-offs, and impact user experience β especially in countries with slower internet connections.
In this blog, I'll walk you through practical steps that helped me reduce a React Native app's APK size by 70%! π₯
π¦ 1. Remove Unused Assets, Fonts & Libraries
- Audit your project and remove unused images, SVGs, fonts, icons, and third-party libraries.
- Check if any dependencies are no longer in use, and uninstall them.
- Delete unnecessary files to clean up your project.
π¨ 2. Compress Images
- Use tools like TinyPNG or TinyJPG to compress images without losing visible quality.
- Smaller images = smaller APK!
πΌοΈ 3. Replace PNGs with WebP Format
- WebP images are typically 25β30% smaller than PNGs.
- You can convert your images to WebP using Android Studio or online converters.
- WebP is supported on Android 4.0+ by default.
π 4. Enable ProGuard to Minify Code
- In your
android/app/build.gradle
, make sure you enable ProGuard in release builds:
def enableProguardInReleaseBuilds = true
ProGuard shrinks, optimizes, and obfuscates your code by removing unused classes, methods, and fields.
This results in a much smaller APK size.
π‘οΈ 5. Add an Effective ProGuard Rules File
In your android/app
, add below generics rules.
/proguard-rules.pro
Hereβs a sample ProGuard configuration optimized for React Native apps:
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
-keep class com.facebook.hermes.** { *; }
# ========== CORE REACT NATIVE ==========
-keep class com.facebook.react.** { *; }
-keep class com.facebook.hermes.** { *; }
-keep class com.facebook.soloader.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.hermes.unicode.** { *; }
# Bridge and native modules
-keep public class * extends com.facebook.react.bridge.NativeModule { *; }
-keep class com.facebook.react.bridge.** { *; }
-keepclassmembers class * { @com.facebook.react.bridge.ReactMethod *; }
# View system
-keep @com.facebook.react.uimanager.annotations.ReactProp class * { *; }
-keep @com.facebook.react.uimanager.annotations.ReactPropGroup class * { *; }
-keep class * extends com.facebook.react.uimanager.ViewManager { *; }
-keep class com.facebook.react.uimanager.** { *; }
# JavaScript and events
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.uimanager.events.Event { *; }
# TurboModules and animation
-keep class com.facebook.react.turbomodule.** { *; }
-keep class com.facebook.react.animated.** { *; }
# ========== THIRD-PARTY LIBRARIES ==========
# React Navigation
-keep class com.swmansion.** { *; }
-dontwarn com.swmansion.**
# Firebase
-keep class io.invertase.firebase.** { *; }
-dontwarn io.invertase.firebase.**
-dontwarn com.google.firebase.**
# Realm
-keep class io.realm.** { *; }
-keep class io.realm.react.** { *; }
-dontwarn io.realm.**
# Async Storage
-keep class com.reactnativecommunity.asyncstorage.** { *; }
# MMKV
-keep class com.reactnativemmkv.** { *; }
# Device Info
-keep class com.learnium.RNDeviceInfo.** { *; }
# Permissions
-keep class com.zoontek.rnpermissions.** { *; }
# Fast Image
-keep class com.dylanvann.fastimage.** { *; }
# SVG
-keep class com.horcrux.svg.** { *; }
-dontwarn com.horcrux.svg.**
# WebView
-keep class com.reactnativecommunity.webview.** { *; }
# Braze
-keep class com.braze.** { *; }
-dontwarn com.braze.**
# ========== NETWORKING ==========
-keepattributes Signature, *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**
# AWS SDK
-keep class com.amazonaws.** { *; }
-dontwarn com.amazonaws.**
# ========== OPTIMIZATIONS ==========
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 3
-allowaccessmodification
-overloadaggressively
-mergeinterfacesaggressively
-repackageclasses ''
-dontusemixedcaseclassnames
-dontpreverify
# Remove logging
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
}
# Debug info
-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile
β This ProGuard configuration ensures that:
- Only required React Native classes are kept.
- Libraries like FastImage, Glide, and SVG remain functional.
- Unused methods and classes are removed to save space.
π± 6. Generate Separate APKs per CPU Architecture
In android/app/build.gradle:
def enableSeparateBuildPerCPUArchitecture = true
android {
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
universalApk false # Smaller APKs per device
}
}
}
π Why? Instead of one fat APK, this generates smaller, device-specific APKs.
π 7. Keep Only Necessary Languages
Reduce resource bloat by keeping only supported languages:
android {
defaultConfig {
resConfigs "en", "fr" # Only English & French
}
}
β‘ 8. Enable Hermes (Faster & Smaller JS Bundle)
Hermes is React Nativeβs optimized JS engineβit reduces bundle size and speeds up startup.
In android/app/build.gradle:
project.ext.react = [
enableHermes: true
]
βοΈ 9 Advanced ProGuard Setup
π Enable in android/app/build.gradle
android {
buildTypes {
release {
minifyEnabled true // Code shrinking
shrinkResources true // Removes unused resources
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
crunchPngs true // Extra PNG compression
zipAlignEnabled true // Memory optimization
}
}
}
π Results
By applying all the above strategies, I was able to reduce the APK size by almost 70%! π
This not only improves the user experience but also positively impacts download rates and app store rankings.
π― Final Checklist
- Remove unused assets and libraries
- Compress images using TinyPNG
- Replace PNGs with WebP
- Enable ProGuard
- Add a solid ProGuard rules file
Hope this guide helps you achieve a super light APK for your React Native app! π
Feel free to share your APK size reduction journey in the comments! π
Top comments (2)
Nice post
the is helpful I am busy with my first ever app creation course using HTML and CSS but I believe your info will be useful later for me