-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is ~8mb the smallest size RN android apk can get? #5037
Comments
Hey alvinwoon, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
Hi @alvinwoon, How did you ran the pro-guard, can you please share the steps. |
@alvinwoon React Native app APKs include JSCore binaries for x86 and ARM. If you don't need x86 you could reduce the size even more. |
@satya164 Thanks! That reduce it down to 5.2mb but crashes the app upon opening. Need to debug more and report back. |
@satya164 After proguard enabled I could not get the build finished, got unable to compute hash error at ":app:packageRelease". Also If I disabled the proguard minify, able to generate the apk but the app crashes always for first navigation with error "Unfortunattely <>...", after that first crash app works perfectly. Do you know how to get the crash reports for this error and fix for the previous error. |
cc @mkonicek |
Thanks @brentvatne, after re-generating key everything works fine, but getting crash reports would be very helpful. |
@MuruganDurai You have 2 options for crash reports,
|
@MuruganDurai How did you solve the 'got unable to compute hash error at ":app:packageRelease"' issue exactly? I tried regenerating the key but no luck |
@Hosain As I said before I copied all the contents suggested from stackoverflow for "proguard-rules.pro" and re-generated the key. -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } okhttp-keepattributes Signature -dontwarn rx.Observale.** okio-keep class sun.misc.Unsafe { ; } -dontwarn butterknife.** -keep public class com.google.android.gms.** -dontwarn android.support.v7.** -dontwarn java.lang.invoke** -dontwarn android.support.** From: Hosain notifications@github.com @MuruganDuraihttps://github.com/MuruganDurai How did you solve the 'got unable to compute hash error at ":app:packageRelease"' issue exactly? I tried regenerating the key but no luck [https://avatars2.githubusercontent.com/u/6378771?v=3&s=400]https://github.com/MuruganDurai MuruganDurai · GitHubhttps://github.com/MuruganDurai Reply to this email directly or view it on GitHubhttps://github.com//issues/5037#issuecomment-168831770. |
@satya164 Thanks for the suggestions. How to remove "React Native JSCore binaries for x86" to reduce the size further. |
@MuruganDurai Remove |
Thanks @satya164 |
@MuruganDurai - def enableSeparateBuildPerCPUArchitecture = false
+ def enableSeparateBuildPerCPUArchitecture = true Upload both these files to Google Play and the users will automatically get the appropriate APK file. If you want to upload to other markets such as APKFiles, which do not support multiple APKs for a single app, change the following line as well to create a big universal APK with binaries for both CPUs. - universalApk false // If true, also generate a universal APK
+ universalApk true // If true, also generate a universal APK |
@SuhairZain Thanks. |
@SuhairZain This seems like a good addition to the docs or even a tutorial. Wink. Wink. |
Using @SuhairZain 's suggestion we got our APK size down from 15.2MB for the universal to 8.4MB for the ARMv7a and 10.3MB for x86. |
Summary: It leads to a reduction of 5-7MB for an app, which is a considerable saving when it comes to emerging markets. Also, I had written a [comment](#5037 (comment)) on an issue which seems to have helped at least 26 people. Closes #16197 Differential Revision: D5978945 Pulled By: TheSavior fbshipit-source-id: 391a992e2d8e62e59fb20e5d5f8e5f59c00b6295
I did some primary experiments on Alibaba's weex which is based on Chrome's v8, similar to ReactNative in architecture. Switching from v8 to duktape bindings significantly reduces the solib size (from 3MB to 300kB), without functional impacts. I suppose the same approach can be applied to ReactNative although its bindings seems more complex. |
@wenq1 That is amazing. |
I have a simple app. Ran proguard and it went down to 7.5mb. I just want to know whether there's other way to reduce the apk size that I am not aware of.
The text was updated successfully, but these errors were encountered: