Last week, the nightly build of my Android project failed all of a sudden. It was apparently related to the 64k method limit than Android poses for DEX-files. I wasn’t aware how much impact the NuGet packages have on that method count. I want to show you my journey to resolving this issue.


When you run into the 64k limit, you can use ProGuard and Multi-Dex to resolve the issue. Make sure to update ProGuard when you use Xamarin.Android 7.2 or lower and target API level 24+.

64k method limit

Android apps run on Dalvik or ART (Android Runtime), depending on the Android version you use. Dalvik has a few limitations, including the 64k method limit. In a DEX-file (which stands for Dalvik Executable), you can only reference the first 65,536 methods. If you exceed that limit you get the following build error in Xamarin:

Tool exited with code: 2.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets : error : trouble writing output: Too many field references: 74105; max is 65536.

My app itself was only consuming 2500 methods of the total. So the rest was added through NuGet packages. The biggest method consumers were the Android support libraries (40503 methods), Google for Analytics (19930 methods) and Firebase for notifications (7258 methods).

Continue reading

Have you always wondered how Xamarin Forms does it’s “magic”? Knowing how things work under the hood is super valuable, especially when things go wrong. This enables you to detect the issue yourself, without having to rely on the knowledge of other developers. In this article a part of the magic of Xamarin Forms will be unraveled, as we take a look under the hood.

Continue reading

We all know security is important, but implementing security measures properly is often a difficult or obscure task. I’m trying to create awareness for this topic, for myself to gain a deeper understanding and for others to benefit from my findings along the way. And the best way to learn is by teaching, right? First up in this app security series is certificate pinning. Why would you need it and how would you implement it in a Xamarin Forms app?

Continue reading

Xamarin Native vs Xamarin Forms. Credits to James Montemagno for the image

Choosing the right tool for the job is always a tricky task. There are so many things to take into consideration. The saying “choosing is losing” is certainly applicable here. Every choice has its pro’s and con’s, and as a colleague said: “you will always be looking for the one thing that’s harder to do in the choice you made”. All it boils down to is making a choice, and sticking to it for a while. Since development lifecycles go so fast, expecially open-source, there might even be a better choice by tomorrow. This can create something we all know as “developers block”, not being able to deliver a single thing. And you will drive yourself crazy over all the options. Same goes for the choice between Xamarin or other platforms, and even for choices within the Xamarin platform itself. In this case the choice between Xamarin Native vs Xamarin Forms.

Continue reading