I have just started react native with expo. My first app has only one App.js file and one component of counter. When I have build it, surprisingly my apk size is 49MB I wonder why its so and how to reduce it without ejecting???
There are a number of reasons for the large size.
- The APK includes native code for x86 and ARM in both 32 bit and 64 bit versions (so basically 4 times the amount of native code).
- The way the managed workflow works is that it includes a bunch of functionality in case it is needed.
- One of the things included in a managed workflow app is the face detector which includes some large data files.
Currently you can’t do anything about the last two points unless you eject, but the Expo team is working on making this better, e.g. If I remember correctly they’ve mentioned that they are working on ways to customise the build to exclude certain things. I believe there are some technical difficulties with this that they need to resolve before this happens.
What you can do something about is the first point. If you build an AAB file instead of an APK file then the Google Play store will send to the device only the native code relevant to the device instead of all 4 versions. So although the AAB file will also be large, the resulting app on an actual device should be quite a bit smaller.
Thanks for the prompt response.
So, I need to keep building my without considering it at this level?? I mean its has only one file and one image, and its 49MB; what If I build the whole app with lots of files and images? It would go more than 1000MBs then - its astonishing.
So the app will start out with most of the space taken up by React Native/Expo code and data, but as you add more of your own code, dependencies and assets, the balance will shift towards your stuff taking up more of the space. If you have a lot of large images then of course the app is going to be very large, but at that point, Expo’s code/data will be a small percentage of your app’s size.
As an example, an APK I build for one of my apps is 45MB. If I unzip it, it’s 119MB.
Of that 119MB, 84.6MB is the native code (between 16MB and 24MB for each of the 4 types). That size is not going to increase as you add more stuff to your app.
There are more static files besides the above.
So over 90% of the unzipped APK is fixed overhead and will not grow as you add more code and assets.
Alright … Thanks for your response.
Now that I am aware of the stuff, I am confident to proceed and finger crossed for the fixes from expo.