App Size - James Montemagno https://staging.montemagno.com/tag/app-size/ https://staging.montemagno.com/content/images/2017/08/MonogramIcon_Orange_NoBuffer.png App Size - James Montemagno https://staging.montemagno.com/tag/app-size/ Hugo -- gohugo.io Tue, 13 Oct 2026 23:21:57 GMT 60 Shrink Your Android App Size with One Setting https://staging.montemagno.com/shrink-your-android-app-size-with-one-setting/ 5ec9f85a9894740045506cee Tue, 26 May 2020 19:18:00 GMT When you are developing Android apps your app size can grow really fast.  We can get so caught up in the day to day that we forget how important it is to keep down the app size of our app. It may not seem like a 20MB APK is that much, but when you have limited internet or reception it can be a real pain.

As an Android developer you have to develop for multiple ABIs, add a ton of resources and translations, and of course you have you have all of your source code and dependencies. You may have a lot of other settings turned on in your app such as startup tracing, AOT, and obfuscation and this can all lead to larger sizes. But do not fear because App Bundles are here to save you!

Android App Bundle logo

Hopefully this is not new to you, but if it is, well you are in for a treat because Android App Bundles solves a bunch of issues when it comes to packaging APKs. When you use App Bundles you package up your app into a special format and Google Play will then optimize your app for your users on demand. What does this mean? It means that with one tiny little setting your app is greatly reduced in size.

I just launched Island Tracker for Animal Crossing and it was my first app that I published with App Bundles and my mind was blown away. When I package up my APK by itself I package for both arm64-v8a & armeabi-v7a. I also use a lot of packages including Sharpnado, Syncfusion, App Center, Xamarin.Forms, Xamarin.Essentials, PancakeView, and more. I also have turned on startup tracing, so for all of that my app is around 30MB as an APK.

File properties for com.refractored.islandtracker.apk showing a size of 29.1 MB

When I toggle on App Bundles and submit it to Google Play.... 12.1-12.5MB!!!!!!! That is a reduction of 67%!

Google Play app download size of 12.4 MB for the reference device and 12.1 to 12.5 MB across all configurations

That is a crazy reduction and it took me all of 10 seconds to enable because I am using App Center to build my app. When you setup your configuration, simply turn on "Build an App Bundle":

App Center build configuration with the Build Android App Bundle toggle switched On

Just like that you are good to go! You of course you can do this manually and publish it or even turn it on in other CI services, but you need to do this ASAP if you ever thought your app was to big.

]]>
How To Keep Your Android App Size Down https://staging.montemagno.com/how-to-keep-your-android-app-size-down/ 598df8f2c121b60019bf3013 Wed, 25 Feb 2015 21:17:20 GMT On my recent visit out to Tonto National Forest to visit one of my best friends, Luke Karrys, I started to realize the importance of trying to keep your app size down when shipping Android apps to Google Play. Working from the middle of the forest is relaxing, productive, and just plain fun, but there is one huge issue, internet and cell reception barely exists in the the middle of no where. 

When I woke up one morning and saw that I had 10 app updates ready to be installed from Google Play I was pretty excited to see what was new and fixed. However, dropping in an out of 3G service combined with an internet connection that will become crippled for everyone else if you download any files resulted in less than stellar results, and had me completely cancel all of my app updates. It had me thinking, why does the Facebook app really need to be 30MB and are all of my apps oversized as well?

There are a few ways you can take to make your app smaller when developing with Xamarin. Additionally, any Android developer can do one simple thing when deploying to Google Play to reduce their app size.

Linking Your Libraries

Xamarin applications use a “linker” in order to reduce your app size. You can browse through the documentation and find out how this works, but to simplify things, it uses static analysis to your app to remove assemblies and types that are not used in your app to bring down your app size. This is for any Xamarin app, so you should also try this out in your iOS app because it can reduce your app size in a default “Hello, World” application from 16MB down to 2.9MB! There are three settings that you can supply from the projects settings:

Don’t Link will do just that, it won’t link anything and you will be left with All of Mono, mscorlib, Xamarin.Android, and a bunch of other stuff:

Link SDK assemblies only is your safest bet and should be your default as it will only attempt to strip things out of Xamarin.Android and any of your third party libraries will not be touched. However, to really bring down your app size you should try out Link All Assemblies, as it will investigate everything and bring down your app size. Be sure to FULLY test your app as it is possible that the linker may be agressive and strip out something you need, and if that is the case you can actually use a [Android.Runtime.Preserve] flag or set a linkskip in your MSBuild to ensure that not all of your libraries get linked. 

So employing this practice with my Bike Now app, which uses Json.NET, Android Support v4, v7, Google Play Services, and Xamarin.Insights, we can compare and contrast the app size when we build our app to support all three ABIs (we will talk about this next!).

  • Don’t Link: 40.7MB

  • Link SDK Assemblies Only: 18.7MB

  • Link All Assemblies: 13MB

As you can see linking correctly can make a huge impact, but we can do even better! 

Splitting your APKs

On Android, there are ABIs (Application Binary Interfaces) that you can support when you ship your application. The most used will be the armeabi-v7a, however there are still tons of devices that support and run the old armeabi ABI and even x86 devices as well. So to ensure your app is reaching the most users you most likely have come into the project settings and selected every single ABI (I know I do!).

However, for every ABI that you select you are actually bundling a separate libmonodroid and sgen with your app. Don’t believe me then rename your .apk to .zip and take a look in the lib folder:

This of course makes sense as you would need a different version of monodroid and sgen that supports that ABI. The issue is that you now have all of these libraries bundle into a single APK and your users will be downloading all of them! The solution for any Android developer (even Java devs) is to simply split up your APKs and upload all of them to Google Play! This way you have a smaller app size across all three APKs. You can do this now with a simple check in your project options:

Now, instead of just a single APK to upload I have three with different and smaller sizes (note it will take longer to create your packages):

  • armeabi-v7a: 10.2MB

  • armeabi: 10.3MB

  • x86: 10.4MB

Notes: 

You may need to close XS after selecting check box and ensure this flag is set in your csproj:

true 

Additionally, your new APKs will be in your /bin/Release folder and will be marked with Signed in their file name.

Keep your users happy and keep down that app size with these quick tips.

]]>