nativeScript huge File size


I half finished the grocery tutorial and compiled the apk. the file size is 18.3 MB. this is huge since it’s basically an Hello world app without additional logic, plugin or library. the command I used is

$ tns build android --release (–all-the-options)

Is there some reason for the huge apk size or there is some other tree shaking command that i can build a production ready apk. thanks.

== UPDATE ==
I added the split configuration in app.gradle. the resulting size is still 13mb. I’m kind of expecting an app with only 2 static page to be under 5mb.


Is this a PAN (Plain Awesome NativeScript) or a NAN (NativeScript ANgular) application?


Sorry new to NativeScript hence I’m not too sure what they are. I’m using the grocery tutorial app. I supposed it’s under “NativeScript with Angular” since the tab name says so.


I am unsure if the Grocery app actually builds with webpack inherently or not (haven’t leveraged that repository in 6+ months).

Have you tried following the webpack build documentation for Nativescript Angular?

Using Webpack to Bundle Your Code

If the base project isn’t using webpack, you should see drastic file size savings with Webpack.


I will try it out and report back my finding.


I used the basic bundling provided by “nativescript-dev-webpack”. the split size went down from 13mb to 10mb. I assume it’s a pretty optimized bundle since I have no additional plugin. It’s a clean half-completed tutorial app. I guess that’s the best NativeScript can do.

my full-fledged ionic app has a size of 8.5mb. I guess there is sacrifices to be made for native performance. I will try out react-native hello world app to see how small the app is.


Do note - RN apps are incredibly small in size, but they do not allow 100% access to the platform’s API.


@Pete.K am curious then, how are they able to get it that small size and are they supporting both arm and x86. Are you saying the apk size is also partly because of the 100% access to the platform’s API? just out of curiosity. Thanks


The 100% access is indeed the reason for the base application size.

In order to implement custom logic and handle each incoming javascript callback according to its metadata (is it a Java/ObjC class? Is it a method? What are its properties?), as well as to synchronize both Garbage collectors (Android’s VM - Dalvik/ART, and V8) we need to distribute a custom-built V8 to run on the device.


Great explanation and i check react and they also around 8mb with hello world template so they are not that small… I also want to find out about using proguard with nativescript apps and is web pack recommended for non angular NS apps…and does it affect the apk size


Proguard is a bit trickier to use in the context of NativeScript because it erases Java classes which are not used anywhere. It is difficult, if not impossible, at the moment to determine what is and what isn’t used compile-time, because you may want to access a class in your JavaScript code, which would have to be explicitly parsed.


Whats the size of your bundles e.g vendor ? if you check those out i’m sure you would see where the extra size comes from


It’s a grocery tutorial app. there is no additional plugin or logic. just 1 static page(i said wrong earlier on. in fact only 1 static page). The following content is from


require("application"); require("ui/frame"); require("ui/frame/activity");

I think it’s just the way it is. NS will generally be twice as big as other app. In return, you get access to raw native api.


“twice as big” may be an exaggeration… there is a base size, but then the size increases as it would anywhere else with each script and plugin included. Metadata size is negligible for native plugins.


Oh i see. I thought it was like the more javascript you write, the more translation code it generated. Then if it’s not the case, i would say NS size is around 10mb base size + your code. while react and ionic is probably 5mb base size plus your code.


check in yourAPP/platforms/android/src/main/assets/app for the bundles i’m taking about


I just did. The app folder size is 4mb. So that’s the real size of my app(10mb with split)? And the rest are NS infrastructure code?