How to build a small size react-native production application

263 Views Asked by At

I have recently started working with react-native (earlier i was working with ionic). My question is related to building the react-native app. My main concern is regarding the size of the application. As far as i know, running the "react-native run-android" command runs the application in development mode with live-reload and checking the size of the installed app,it turns out to be almost 52MB.

Checking with the some answers from stackoverflow , i was told to use the following commands for the building an apk:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

cd android/ && ./gradlew assembleDebug or cd android/ && ./gradlew assembleRelease

But these commands still create an application of around 30MB, that too for a starter application. If i compare it with ionic framework the "ionic cordova run android" directly builds an install-able application (without the need of signing it) of reasonable size.

Please tell me if i am doing anything wrong.

2

There are 2 best solutions below

2
On

try adding

ndk {
    abiFilters "armeabi-v7a", "armeabi" // includes ARM SO files only, so no x86 SO file
}

inside

buildTypes {
    release {

of your app/build.gradle and see how much size will change

1
On

React native will always be far bigger than an Cordova app of the same complexity. Cordova runs in a web browser. React Native doesn't, so it has to come with its own javascript interpreter. That's a large .so file. You may be able to make it a bit smaller, but you're not going to get a huge decrease from there.