Xamarin Forms: how to troubleshoot Android crashes when all you see is Java and Android native code in the Stack Trace (Teaser, Part 1)
To develop our iOS and Android apps, our team uses Xamarin Forms and MvvmCross and we love it!

Here are some of the pros -
- Cross platform (iOS, Android, UWP, WPF, Mac OS, Xbox, and more!)
There no need to groom a story among 2 or 5 different teams — the same team that understands and implements the business requirements for iOS is the same team that understands and implements the business requirements for Android or any other platform.

In addition 99% of our code is written and maintained in one place (through .NET Standard or Portable Class Libraries)— and it works on iOS, Android, and any other platform we choose to target.
2. Access to native SDKs and APIs
.NET is a rich environment with thousands of APIs available to make us more productive.

We get not only access to the .NET APIs but we also get access to all of the native iOS and Android APIs — we have more options than developers just writing native (Swift, Objective-C, or Java) apps!
3. Great Tooling
We can use IDEs such as Visual Studio for Windows or Visual Studio for Mac — and many other tools available in the .NET/C#/Xamarin ecosystem. Microsoft has been developing tools for software for decades — and it shows.

Much more… — I’m serious when I say Xamarin Forms and MvvmCross rock, much love sent their way.

But this is just an introduction and my main focus in this article is the pickle below — so let’s move on.
The Pickle
Every once in a while we run into a pickle.

Here’s an example of an Android crash we’ve recently seen on App Center:

A few things to notice about the Stack trace -
- There’s no trace of our actual code in there — this crash did not originate in any of our Viewmodels, Views, or Services.
- There’s no trace of MvvmCross causing the crash.
- There’s no trace of Xamarin Forms or Mono causing the crash.
- Who is “Zygote”?
The good news is that we are not seeing any users reporting these crashes — the app is probably in the background when it occurs.
But it’s still a pickle: all we see is Android and Java code — what can we do?
Troubleshooting
Using Xamarin Forms and MvvmCross allows our team to focus on business value.
But like everything, there’s always two sides to a coin: by using the high level abstractions such as Views, Viewmodels, and Services we implement in our Portable Class Library (PCL) we are a couple of layers away from the native code, in this case Java/Android.
Note: I am glad to make this “sacrifice”, even native developers are far away from assembly and other non zeros and ones abstractions — I much prefer to be more productive and deliver business value fast than play in the iOS or Android lower levels.
I’m lucky enough that I have access to a multitude of sources and resources to help me out.
Some great folks from the Xamarin Team have suggested the following -
- Configuring your app to catch all exceptions in Android
See -
Spoiler -

2. Use mono-symbolicate

3. Handle “Application Not Responding” (ANR) events and view them in the Play Console
For example, see https://developer.android.com/topic/performance/vitals/anr
Conclusion (or is it?)
Now there’s a reason I called this “Teaser, Part 1”: our team has not yet had the time to dig in and explore these possible solutions.
The goal is get some kind of managed stack trace, so we can see where there might be a potential issue — in our code, in the MvvmCross code base, in the Xamarin Forms/Mono code base, or somewhere else.
I hope you got some value from the tips above and once we’ve solved it, I’ll come back and give more details — including if any of the above helped or if something else did.
In the meantime, all we can do is eat the pickles.

Good times!
Let me know what you think at @ehuna