6

This isn't a general gripe about the bloat of Android apps nowadays*, but a very specific question:

If you install Android Studio 2.3.3 and create the "Hello world" sample app (as described in the Building your first app official tutorial), then build a release APK, the resulting file is 825KB (I tested this on Linux, but I suspect the output is the same on other OSes).

Android Hello world release build

I've already enabled ProGuard and there are no images or other resources.

What goes in that APK by default?

Why?

How can that bloat be taken out?

By comparison, in 2013 a Hello World app was under 10Kb.

* I remember when decent fully-functional apps were a few hundred KBs, and by comparison a PWA like Uber is 1% the size of the corresponding Android app

Zoe
  • 27,060
  • 21
  • 118
  • 148
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404

2 Answers2

6

Exclude all AppCompat libraries and you will see size decrease to about 100kb.

appcompat v7 is automatically attached even if you do not use it at all

In your build.gradle, exclude from "dependencies": compile 'com.android.support:appcompat-v7:26.+

You'll also have to edit res\values\styles.xml to become only this:

<resources><style name="AppTheme" parent="android:Theme.Light"></style></resources>

(make sure to remove the <!-- Customize your theme here. --> lines). Also, in MainActivity.java, change the extends AppCompatActivity part to

public class MainActivity extends Activity
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
statosdotcom
  • 3,109
  • 2
  • 17
  • 40
  • Tried to, but without [that library](https://developer.android.com/topic/libraries/support-library/packages.html#v7-appcompat) the build fails with `Error:(99) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.` – Dan Dascalescu Jun 19 '17 at 02:49
  • 2
    Change the following file: **src\main\res\values\styles.xml** to this: "" , as an example. This will desobligate you to use AppCompat, enabling you to del this and dropping dramatically the size of your APK. You can use another style if you want, but one thing you can be sure, AppCompat is the responsible for your "naked" apk weight all those hundreds of kbs. Exclude AppCompat and you will have a tiny apk. Best luck. – statosdotcom Jun 19 '17 at 03:08
  • 1
    Nice, only 107KB now. I've incorporated your suggestions into the answer. Thanks! – Dan Dascalescu Jun 19 '17 at 04:23
  • Dan, I really thank you for your patience and consideration. I am glad that it worked well. Best regards. – statosdotcom Jun 19 '17 at 05:15
0

Turns out that by removing all sorts of resources and using insane compression, an empty APK can be brought down to 678 bytes (!).

Thanks to Udayraj Deshmukh for pointing out a blog post detailing how to reduce an Android APK's size by 99.99%.

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404