Visual Studio Xamarin Android Error: Too many field references: 67844; max is 65536

Q:

We are having a rough time battling all the errors in Visual Studio Xamarin Android project.

I’m compiling fine, but my coworker gets a Java.exe error 2 on build (trouble writing output: Too many field references: 67844; max is 65536. (TaskId:342). Yes, we’re running the same code. He is running on a virtual machine (Windows 8.1) and I’m running on Windows 10. That’s the only difference. Have you any guidance on this issue?

A:

64K method count limit it’s a well know Android problem. The following blog covers the issue and provides some solutions http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

Our standard reply re: 65K method limitation is:

  1. If you are using the Play Service SDK (such as Drive/Plus/Account), Google now offers the ability to selectively include different APIs into your project. See details in the following link: https://developer.android.com/google/play-services/setup.html
  2. Android now officially supports multidex. See details in the following link: https://developer.android.com/tools/building/multidex.html