React-native: How to reduce Android apk size? (build by React Native) What's the minimum Android APK size?

Created on 15 Jan 2018  Â·  11Comments  Â·  Source: facebook/react-native

Is this a bug report?

NO

Have you read the Contributing Guidelines?

No

Environment

Environment:
OS: macOS High Sierra 10.13.2
Node: 8.9.4
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.51.0 => 0.51.0


Background info

I build a simple App that focus on Android for now, the generate APK size is about 8~9 mb
(6 screen, 4 image that add up doesn't exceed 500kb, just logo and splash screen)

My question is

What's the minimum size a React Native Android APK can get?

there not much info on Google,
here is few of them:

https://github.com/facebook/react-native/issues/5037
https://hashnode.com/post/how-to-reduce-the-app-size-in-react-native-cj6ohocv002rqt9wuy24etkee
https://facebook.github.io/react-native/docs/signed-apk-android.html
https://stackoverflow.com/questions/38184734/react-native-for-small-size-apk-with-low-internet-bandwidth

seem like

def enableProguardInReleaseBuilds = true
def enableSeparateBuildPerCPUArchitecture = true

is the most I can do,

it's 2018 and newest React Native version is 0.52,

is there anything more I can do to reduce Android APK size?

the ideal size should be around 1~3mb

Thank you very much :)

Ran Commands For Stack Overflow Locked

Most helpful comment

You could reduce the size of your launcher images by a good bit. Look up how to compress your images efficiently. You are also creating an api with both x86 and arm versions. x86 alone is 3.1mb. Without that and more efficient images you could reduce your apk by 4-5megs

All 11 comments

Use the apk analyser in Android studio and see what is taking up the space then post the screenshot back here

@thevolcanomanishere no problem~ Thanks! would come back soon

Here is result

@thevolcanomanishere
1 1
2 1
3 1

Here is source code screenshot

image

15 file under /src

image

I used:

here is full list:
image

appreciate @thevolcanomanishere

You could reduce the size of your launcher images by a good bit. Look up how to compress your images efficiently. You are also creating an api with both x86 and arm versions. x86 alone is 3.1mb. Without that and more efficient images you could reduce your apk by 4-5megs

Your react-native-splash-screen package is unnecessary. You could create a much more lightweight splash screen by making it yourself

@thevolcanomanishere
Thanks!
will do!

@facebook-github-bot stack-overflow

Hey @1c7, thanks for posting this! @lwinkyawmyat tells me this issue looks like a question that would be best asked on Stack Overflow. Stack Overflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

How to Contribute • What to Expect from Maintainers

Was this page helpful?
0 / 5 - 0 ratings