uLYsseus
uLYsseus

Reputation: 1006

Android: Why is the size of apk file smaller than the entire project

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?

Upvotes: 0

Views: 2588

Answers (5)

Wander Nauta
Wander Nauta

Reputation: 19695

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.

Upvotes: 1

zgc7009
zgc7009

Reputation: 3389

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.

Upvotes: 0

zmarties
zmarties

Reputation: 4869

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!)

Upvotes: 1

Sajad Karuthedath
Sajad Karuthedath

Reputation: 15837

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

Upvotes: 4

Kuffs
Kuffs

Reputation: 35651

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.

Upvotes: 2

Related Questions