Reduce APK size in React Native

Reduce App Size in React Native:

We all have faced problems related to the size of the built apk in React-Native. The size of the apk is usually very high . This eats up a lot of space in the phone’s storage. Let’s look at a few methods to a…


This content originally appeared on DEV Community and was authored by DEV Community

Reduce App Size in React Native:

We all have faced problems related to the size of the built apk in React-Native. The size of the apk is usually very high . This eats up a lot of space in the phone's storage. Let's look at a few methods to avoid large apk size in the final bundle.

Remove Codes and assets.

One simple method is to use light-weight assets. Use jpg instead of a high quality png image (if not required). Use vector icons(Prefer React Native Vector icons). Optimize your image files using some tools like tinypng.com. Also, remove unused codes and JS files.

Prefer light-weight node modules

You can use alternate node modules to reduce the size of APK by finding the weight of your current node modules by the use of cost-of-modules(npm install -g cost-of-modules).If any module is of high cost, replace it with less cost alternatives.
Image description

Compress Java Bytecode

Navigate to android/app/build.gradle .Set the def enableProguardInReleaseBuilds to true.This would enable Proguard to compress the Java ByteCode leading to reduction in the apk size.

Separate APK for separate CPU architecture

Navigate to android/app/build.gradle .Set the def enableSeperateBuildPerCPUArchitecture to true.This would build different apks for different CPU architecture(x86 and arm).Upon publishing on playstore, playstore will automatically deliver required apks according to the phone's CPU Architecture.
Image description


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2022-02-23T05:57:32+00:00) Reduce APK size in React Native. Retrieved from https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/

MLA
" » Reduce APK size in React Native." DEV Community | Sciencx - Wednesday February 23, 2022, https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/
HARVARD
DEV Community | Sciencx Wednesday February 23, 2022 » Reduce APK size in React Native., viewed ,<https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/>
VANCOUVER
DEV Community | Sciencx - » Reduce APK size in React Native. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/
CHICAGO
" » Reduce APK size in React Native." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/
IEEE
" » Reduce APK size in React Native." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/. [Accessed: ]
rf:citation
» Reduce APK size in React Native | DEV Community | Sciencx | https://www.scien.cx/2022/02/23/reduce-apk-size-in-react-native/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.