DEV Community

Mubarak Basha
Mubarak Basha

Posted on • Originally published at proandroiddev.com on

How I Optimize My Android App from 15MB to under <2MB

How I Optimize My Android App from 15MB to under 2MB
How I Optimize My Android App from 15MB to under 2MB [IMG Credit: (Mubarak Basha)]

In this blog, I’m going to share my personal experience of how I Optimized my FOSS Android app by ~90% , which led to more downloads and positive feedback. I will also share some practical ways you can do the same for your app and more. Let’s begin.

Update (July 2025):
This article was featured at #2 in Android Weekly Issue #682.
Also, my open-source app MBCompass got featured in the following issue #683 under Libraries & Code!

Why is optimizing necessary ??

Optimizing Android apps offers several benefits, including but not limited to:

  • Faster downloads
  • Reduced storage consumption
  • Improved overall performance.
  • Reduce internet bandwidth and many more.

The app that I optimized.

In this blog, I’m going to share MBCompass as an example, which is an open-source, simple yet feature-rich Android Compass app

When I first built MBCompass with new features and improvements on v1.1.4, like:

  • Showing the current location on the map.
  • Updated Compass rose.
  • Day/Light theme support.

In this process the APK size was significantly increased to 15.5MB. Most users expect these tools to be lightweight, ideally a few MBs at most.

People even complaining about my app on its size when I posted it on platform like reddit.

So, I decided to reduce the APK size but without compromising the feature that has already before.

What Was Taking Up Space??

MBCompass v1.1.4 APK increased to 15MB compared to previous release
MBCompass v1.1.4 APK increased to 15MB compared to previous release

When I analyze the MBCompass APK using Android Studio’s APK Analyzer tool , the issue was clear, most of the space was taken by MapLibre’s native binaries, which I use this library to just show the current location on the map.

That was one of the features the library provides. For that single feature, I’ve used the big, powerful library.

Switching to a Lightweight Alternative

I started looking for a smaller, simpler map library. That’s when I found osmdroid (which is a low-level library*) -* a lightweight replacement for Android’s MapView.

After switching to osmdroid, I had to manually handle:

  • Location permissions
  • Map tile loading
  • Overlays and markers

It was a bit more work, but gave me full control and customization.

Step-by-Step Optimizations Process

After switching to a different library, some other processes still have to be done before releasing the app to production.

  1. Replaced MapLibre with osmdroid
  • Dropped the MapLibre dependency and rewrote the location feature using osmdroid.
  1. Shrink resources using R8 + Proguard

In build.gradle(:app):


 buildTypes {
        release {
            isDebuggable = false
            // Enables code-related app optimization.
            isMinifyEnabled = true

            // Enables resource shrinking.
            isShrinkResources = true

            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }

    }
// ...
Enter fullscreen mode Exit fullscreen mode
  • isMinifyEnabled = true: removes unused code/imports.
  • isShrinkResources = true: removes unused icons, drawables, layouts, etc.
  1. Optimized Image Assets
  • Replace the use PNGs/JPEGs with WebP for Images.webp

Final Result

MBCompass v1.1.8 APK reduced to just 1.7MB
MBCompass v1.1.8 APK reduced to just 1.7MB

After these steps on v1.1.8 latest release , I brought the size down to just 1.7MB —  a reduction of around 90%. And importantly! The core experience didn’t change instead it improved.

What I Learned

  • Don’t use a third-party library when you’re not fully utilizing it.
  • Use Prograud and R8 to optimize APK.
  • Smaller apps == happier users, especially on low-end devices
  • Keep utility apps small, users appreciate it

You Can Try It

Conclusion

That’s pretty much it, I talked about how I found what was bloating my APK, switched to a lighter map library, enabled R8 and resource shrinking, and cleaned up resources. All of that helped me bring my app from 15MB down to 1.7MB without losing features.

If you’re working on something similar, give these steps a try.

And if you’re curious, you can check out MBCompass on GitHub or F-Droid. Feedback or contributions are always welcome! Thanks for reading. I will see you on my next interesting topic.

Signing off, Mubarak Basha

LinkedIn, GitHub, X


Top comments (0)