Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 23, 2022 05:57 am GMT

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 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


Original Link: https://dev.to/riteshshukla04/reduce-apk-size-in-react-native-aj6

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To