I started testing size impact of using react-native in existing android project. When created a simple android project(template project with navigation drawer) and created .apk file, it's size was 1.1 MB
in release mode.
Then I tried to integrate react-native with it by following steps in doc, https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
after completed this integration and updated my progaurd-rules.pro file with progaurd steps defined on here, https://github.com/luggit/react-native-config/blob/master/Example/android/app/proguard-rules.pro
Proguard-rules.pro file contents are similar to,
# React Native
# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.proguard.annotations.DoNotStrip *;
@com.facebook.common.internal.DoNotStrip *;
}
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
void set*(***);
*** get*();
}
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
-dontwarn com.facebook.react.**
# okhttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
# okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
Now, size of my release .apk file has jumped to 7.9 MB
. This is too much. I can see various e-commerce apps on play store with total size of 9-12 MB
.
My Hybrid react-native app is the most basic app, Which has just two activities which are doing almost nothing.
To verify my findings, I created a new react-native app by following this doc, https://facebook.github.io/react-native/docs/getting-started.html
When I generated release .apk file for this pure react-native project, again the basic Awesome App
.apk size was 6.8 MB
.
This is unacceptable. React native is adding too much size to apk.
Is there any further improvement possible in my progaurd file
? Anything else can be done to improve this?
It will be really helpful, If anyone can share size impact on his/her app due to React native.