Question

I am definitely a noob at understanding this as of now, I noticed usually that the apk file is much smaller than my Android Projects. How is that happening? Is it always like this? I got this doubt while I was compressing an entire project to zip file, it was showing that the disk size is 128MB...(noticed it then the first time) whereas the actual apk is only 22.4 MB. why is this difference?

Was it helpful?

Solution

An APK is an Android application package file. Each Android application is compiled and packaged in a single file that includes all of the application’s code (.dex files), resources, assets, and manifest file. The APK file is basically a .zip file

OTHER TIPS

Your project contains all of your source files and files used only by the IDE. The apk only contains compiled files which are smaller.

Also, images/resources etc are compressed in the apk.

Android projects (in general) contain source code, which gets compiled to class files that end up in the APK.

Compiled files are smaller than the source code - for example they strip all the comments out of the file (you do include comments in your source files don't you!)

In addition to the other answers, you're probably using something called ProGuard which further compresses your project by shortening field names, removing dead (unused) code, merging classes, and dozens of other tricks.

Check out the FAQ for more about ProGuard.

It has to do with how Android compiles your project. It basically dumps the bulk, compresses the resources, and compiles everything into a simple binary. It will happen with almost every type of programming, your final build will usually be smaller than your total project (unless you include outside sources in your build). There is a lot of bulk in code that get's stripped during compilation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top