< Back

September 26th, 2019

The Cowrywise android app: Why size matters to us

{ Engineering }

The Cowrywise android app: Why size matters to us


Why Should You Bother About Your App’s Size?

At the moment, many Cowrywise users are between the ages of 18–34. They range from university students, NYSC Corp members and the working class. These are people who also use social media apps that are about 40MB each.

How Does The User Think?

Given the heavy use of such apps, it is only natural for smartphone users to place them on a higher pedestal. It’s key to avoid competing with such apps for storage space. Yes, your app is essential but is it as necessary as Instagram?

I’ve spoken to a couple of people (who have never heard of Cowrywise but want to save money). The conversations usually end up with this: “I don’t need another app that takes space on my phone”. In other words, “I’d rather have Instagram than a savings app that takes more space”. Size is a factor when these users want to download a new app.

According to the Alliance for Affordable Internet (A4AI), 1GB of data should not be more than 2% of monthly income. Let’s put this in some perspective. If your app size is 48MB, a user with a 1GB internet subscription would be using 5% of their data bundle to download your app.

Currently, our Android app size sits at a measly 8.5MB download size on my phone and takes up 28MB after installation. GTBank’s app, on the other hand, has a 38MB download size and takes up 151MB. In the finance space, we’re doing pretty well. The image below shows how our app’s size compares to other finance apps.

Cowrywise vs other finance apps. Source: Google Play Console

Our Approach: Continuous Android App Size Reduction

When we launched the first version of the mobile app, the size was ~24MB. Good, but for every update pushed, it was still about the same size.

Every bug fix, new feature, or text change we made, required the user to download another 24MB — 2.5% of 1GB. This was a huge turn-off. In the following paragraphs, I’ll show you how we solved this problem.

1. Split APKs

defaultConfig {

    ...
    //some code ommited for brevity
    
    ext.abiList = ['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64']
    splits {
        abi {
            enable true
            reset()
            include(*abiList)
            universalApk false
        }
    }

    android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // Shift abi over by 8 digits
            def abiFilter = output.getFilter(OutputFile.ABI)
            int abiVersionCode = (abiList.indexOf(abiFilter) + 1)
            // Merge all version codes
            output.versionCodeOverride = variant.mergedFlavor.versionCode + abiVersionCode
        }
    }

    javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath true
        }
    }
}

2. Android App Bundles

The Android App Bundle is Android’s new, official publishing format. It offers a more efficient way to build and release your app. App Bundle results in smaller app sizes and faster build times. With this, new users download approximately 8.5MB of the app. Also, updates and bug fixes are between 2–6MB. Awesome isn’t it?

App bundle

3. Minify and Obfuscate Code

To make your app as small as possible, you should enable code shrinking (minification). This helps remove unused code and resources from your release build. Enable obfuscation to shrink class, method, and field names. Asides from reducing app size, it also prevents reverse engineering of your app.

...
//some code ommited for brevity

buildTypes {
  release {
    minifyEnabled true
    shrinkResources true
  }  
}

4. Remove Unused Assets

Many times, we receive images, fonts, and other assets from our product designers. Eventually, we don’t use these images in the release version of the app itself. There’s so much to do that we sometimes forget to remove them. Thankfully, there’s an Android Studio plug-in that does this and much more. It’s called Size Analyzer. Another hack is to load images from firebase storage. That way, you don’t need to store images on your app.

Remove unused resources

5. Do you need that Third-party library? Probably Not.

Opensource libraries are great. However, do you need to add an extra 500kb to your code because of a minor change? A couple of things you would need an opensource library for can be done with the stdlib or with Kotlin and KTX.

The Result

In the chart below, you can see how the Cowrywise android app size has reduced over time. We’re constantly improving our savings and investment platform to appeal to a wide variety of users.

Cowrywise app size over time
Source: Google Play Console