Old MVVMCross Xamarin solutions & the looming Android 10 Deadline

November 2 is coming close, be proactive to avoid a meltdown

The First Prototype
Jul 7 · 4 min read

sing cross platform frameworks like Xamarin has a lot of pros, in terms of the shorter learning curve and time of development. But changes needed due to unforeseen change in the native iOS & Android SDK’s is one of the disadvantages, as you will see in this article.

Introduction

You must have read about the important changes to the Android Play Store requirements, from an article just published by Microsoft. It’s based on the deadline outlined by Android and summarized in this image:

Image for post
Image for post
Google’s explainer image showing the Timeline of different requirements

The Google Play Store requirements state that, after November 2nd 2020 all app updates to Android apps will need to target the Android 10 (Q API Level 29) framework.

Fix for most Xamarin Apps

For most Xamarin and Xamarin.Forms apps, this is an easy 4-step fix:

Image for post
Image for post
4-step change to comply with Android 10 changes
  1. Open your Xamarin Solution (SLN) file in Microsoft Visual Studio, and double tap on your Droid project to open the Project Options
  2. Select the General Build options in the menu
  3. Change the Target Framework to Android 10 or newer
  4. Press OK, and you are done!

Why isn’t it that easy for MVVMCross?

If you are using an “MVVM framework” library (nuget package) like MVVMCross, you might have a lot of work ahead of you. These libraries are heavily tied in with the code of Xamarin Native solutions, and are used mainly to simplify navigation and code sharing, years before Xamarin.Forms became a lot more stable. So what’s the issue? As detailed on StackOverflow, due to changes in the Android SDK unforeseen by the MVVMCross framework, these apps cannot simply target the Android 10 framework. Your app will crash on load, unless you update to the MVVMCross version 6.4.1 libraries.
Updating Nuget packages is generally pretty easy, isn’t it? Well, the fix is not that easy because the updated versions of these MVVM framework libraries do not support the >5 yr old target framework of your “Core” projects, which probably use .NET Portable PCL 4.5 — Profile111. Tomasz, maintainer of the library, pointed out that there are potential workarounds like rolling your own MvxLayoutInflater code or perhaps just stop using binding inflation with MvvmCross, and do all your bindings in code behind like on iOS, but I haven’t tried those yet.

So how do I update?

Theoretically, these are the steps you should follow to update your library version:

GIF Sarcastically telling you to pull your hair out
  1. You must first update your Core PCL project target framework to .NET Standard 2.0. There are several articles talking about this.
  2. Once you change that, now all your 3rd party libraries will require updates to a version that can support the newer Core target framework.
  3. You will have a lot of errors due to years of changes in those libraries (could be greater than 2000).
  4. Once you resolve 90% of those errors with simple fixes, a lot of changes will be needed to be made in all projects because the Setup of MVVMCross is a lot different from before.

My recommendation though is not to do try updating your library version! From my trials, I learned that the easiest way to update library versions is to take the latest working sample provided by MVVMCross with the newest target framework and libraries, and just make replacements to it, replacing pages piece by piece. As pointed above, perhaps try the potential workaround mentioned by Tomasz.

Why do I know about this?

Last year, I spent some of my free time trying to do the migration for an app during my free time as a challenge, following the tutorials & advice I received online, and picking brains of Xamarin consultants leading to a roadblock and a lot of realizations. For an app I just inherited, a major consulting company spent several months with the Xamarin apps doing the MVVMCross framework “migration”, and we are still fixing bugs created.

Is the migration going to make the app last for a while?

The migration isn’t all unfortunately. The other change made around the end of 2018 was that Android changed all its native libraries to “AndroidX”. From my conversations with the creators of MVVMCross, there is only an unofficial version of the library that supports AndroidX, but it’s workable. You don’t need to make this change for now, but with the soon to come MVVMCross version 7 libraries, you can keep publishing updates to your Xamarin MVVMCross Android apps for the foreseeable future.


MVVMCross is awesome!

The app I recently inherited, used MVVMCross with the 2013 version of the library and was pretty stable. The company only decided to migrate to the latest version, because of this Android 10 requirement. Taking that into consideration and despite this issue, I highly commend the framework creators and contributors for a fantastic library. Don’t forget to share this with your friends, as they may be unaware of this looming deadline. Please let me know your thoughts on Twitter or comment here.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Sign up for Best Stories

By Dev Genius

The best stories sent monthly to your email. Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

The First Prototype

Written by

Developers building things, on here to share knowledge. Featured blog for PlanetXamarin.com github.com/saamerm linkedin.com/in/saamer

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

The First Prototype

Written by

Developers building things, on here to share knowledge. Featured blog for PlanetXamarin.com github.com/saamerm linkedin.com/in/saamer

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store