Forum Xamarin.Forms

Urgent: Xamarin.Forms.Maps does not build -> COMPILETODALVIK : UNEXPECTED TOP-LEVEL

Hi Xamarin Masters,

I have been banging my head the whole day trying to figure out why can't i build my android project (windows phone project works in this case, android project is the only problem). Here's what happens:

  1. Create a cross platform application (portable or shared), any of the two will do.
  2. Build all projects (works good, no problem)
  3. Add dependencies for android project the following,
    • Xamarin.Forms
    • Xamarin.Forms.Maps
    • Google Play Services Lib (added by default)
  4. Build the android project with the new added dependencies (not good)
    • does not build the project
    • just says "Build failed", but without errors

I cannot seem to understand fully what it asks out of me. My colleagues at work did not even have ideas about it nor your forums or communities does have any close answer to this simple but big problem.

We are now trying to opt to use the native implementation of the maps over the android platform only (on the cross platform project). Such a dirty long work, but we don't have any choice. We need to get things done and as we are getting the deadline very soon.

Any urgent help and suggestions from you guys is much appreciated. It bugs me a lot, to create a separate native map platform over the android project in the cross platform solution.

Jeffrey S. Albano
Mynd Dynamic Team, Inc.


  • carleslscarlesls ESMember

    The same here... the compiler doesn't find COMPILETODALVIK when the Google Play Services are added -which is a requirement/dependency for Forms.Maps-.

  • @jeff.albano thanks for the update

  • BrandonBooneBrandonBoone USMember ✭✭

    where is this Android Options -> Andvanced Tab -> Java Max Heap Size = 1G?
    I do not see it

  • MateuszKierepkaMateuszKierepka PLDeveloper Group Leader

    Good example is here:
    On several machines we have to switch to 64bit of java

  • StevenMoncayoStevenMoncayo COMember

    I changed Java Heap Size to 1G but still the problem persists

  • FndFnd TWMember

    Sorry,I use VS2013 IDE and have same problem,

    how to Set Java Heap Size to 1G in VS2013?

  • AlisonFernandesAlisonFernandes USMember ✭✭
    edited April 2015

    @jeff.albano Thanks for the tip, always forgetting about the 1G prob.

    In Visual Studio,

    1. Right mouse button click your Droid project
    2. Properties (ALT+Enter)
    3. In the left vertical menu, click on Android Options
    4. Click the Advanced tab (it's after the Packaging and Linked tab)
  • KimNieblingKimNiebling DKMember ✭✭

    Thanks @jeff.albano. Changing the Heap Size to 1G resolved the issue

  • Chandan.3739Chandan.3739 USMember
    edited June 2015

    Thanks!!! Setting, Android Options -> Andvanced Tab -> Java Max Heap Size = 1G solves the issue but you need to Set API level 21 as well.


    Thanks, that fixed my problem.

  • same problem... fixed! thanks

  • EnriqueZavaletaEnriqueZavaleta USMember ✭✭

    After doing what @jeff.albano said (thanks Jeff), there was still 22 errors, but debugging the app in a real device instead of direct build action unexpectedly works

  • AbyMathewAbyMathew USMember

    I simply stopped the java vm that was up and restarted visual studio

  • DavidStrubeDavidStrube USMember

    I just had this problem. Rather than trying to fix it by increasing the heap size, I was able to fix it by going to Build -> Clean Solution, and then Rebuild Solution.

  • VivekNigamVivekNigam USMember ✭✭

    I changed Java Heap Size to 1G but still the problem persists. i still get the error java.exe exited code 2. i am using visual studio 2015

  • me too i want help plz

  • AceCoderLauraAceCoderLaura AUMember ✭✭

    Uninstall any versions of the JDK that aren't built for your computer's architecture. I had a x86 version of the JDK installed and my PC is x64. That fixed the issue for me.

Sign In or Register to comment.