Multidex? RRS feed

  • Question

  • User11137 posted

    I think I have an app that is hitting the dex method limit of 65k, mostly due to Google Play Services. Its hard to tell because the error I get from the Xamarin tooling is just Java.exe exited with code 2 :) Is there any facility to generate multiple dex files and use Multidex with Xamarin.Android?

    Wednesday, February 4, 2015 6:33 PM

All replies

  • User209 posted

    Ehm, I don't think that is the problem. If you look at the architecture and the resulting apk file you will discover that you have a DLL containing all your code. The java code is simply wrappers and the initialization of your app using the mono runtime.

    Instead you should try increasing the allowed memory when compiling to 1G. You can do that in the project properties.

    Wednesday, February 4, 2015 7:38 PM
  • User11137 posted

    Nope, dex is failing with: trouble writing output: Too many method references: 69597; max is 65536

    Wednesday, February 4, 2015 7:40 PM
  • User11137 posted

    So it isn't getting to that stage.

    Wednesday, February 4, 2015 7:40 PM
  • User209 posted

    I am not experiencing any of this with apps using Google Play Services. I think your best bet is to either wait for someone with more knowledge about the build process answering this question. Or open a bug report on the Xamarin Bugzilla: http://bugzilla.xamarin.com/

    Wednesday, February 4, 2015 7:43 PM
  • User11137 posted

    Well, Play Services alone eats up at least 20k of that 65k budget. In this instance another large library is eating about 28k of the budget. And the rest is eaten up by miscellaneous gunk.

    Is the dexing one of the last steps? If we can inject some extra things, like trying to use multi-dex, will it mess with Xamarin's build steps?

    Wednesday, February 4, 2015 7:48 PM
  • User11137 posted

    Could any Xamarin folks weigh in on this before I try messing with stuff? Far as I can see, I would have to at least override a target, and presumably create some bindings for the multidex support library, but there could be other more problematic roadblocks I have no knowledge of.

    On a related note, does Xamarin have bindings for the more modular version of Google Play Services? And could nuget packages such as Xamarin.Forms.Maps perhaps use a more constrained subset of said?

    Thursday, February 5, 2015 3:08 PM
  • User11137 posted

    Well, I'm going to try it out, and we'll see how it goes. I'm guessing the safes thing will be to change the application name to the multi dex application to try to cause all the dex files to be loaded as early as possible, Not sure when Xamarin will try to touch them.

    Thursday, February 5, 2015 7:36 PM
  • User11137 posted


    I've bludgeoned it into working through some mild evil. How likely is it to start a fire? :)

    Friday, February 6, 2015 8:30 AM
  • User2422 posted

    I just hit this error today, is multidex part of the official Xamarin Studio / VS yet OR do I need to look into more "mild evil" details like the above very helpful articles?


    Wednesday, November 2, 2016 6:21 AM
  • User191514 posted

    BUMP ^^^

    When I enabled the "multi-dex" option in Xamarin for an Android application, my app crashes with a NULLReferenceExceptio. This is because a FindViewById(Resource.Id.resourceName) is returning a null view which I try to access a property of later in the app.

    This only happens when I hit the "Too many method references: 69597" and turn on "multi-dex" for the Android app.

    Any help from Xamarin would be awesome!

    Thanks Xamarin Team for all your hard work, Cheers

    Friday, January 27, 2017 12:26 AM