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

  • Question

  • User56231 posted

    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
      • Only hint: COMPILETODALVIK : UNEXPECTED TOP-LEVEL error

    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.

    Sincerely, Jeffrey S. Albano Mynd Dynamic Team, Inc.

    Tuesday, August 5, 2014 2:56 PM

All replies

  • User68520 posted

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

    Monday, August 18, 2014 11:30 AM
  • User56231 posted

    Hi Carl,

    Xamarin support already given me the answer to this. You have to set your android project's property setting to: Android Options -> Andvanced Tab -> Java Max Heap Size = 1G

    Check also if your manifest have these settings:

    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="<PACKAGE NAME>.permission.MAPS_RECEIVE" />
    <permission android:name="<PACKAGE NAME>.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
    <application>
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="<YOUR_API_KEY>" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    </application>
    

    Cheers..

    Tuesday, August 19, 2014 2:16 AM
  • User79293 posted

    @jeff.albano thanks for the update

    Wednesday, October 15, 2014 9:16 AM
  • User68083 posted

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

    Tuesday, November 11, 2014 2:44 PM
  • User459 posted

    Good example is here: http://www.wikihow.com/Increase-Java-Memory-in-Windows-7 On several machines we have to switch to 64bit of java

    Friday, November 28, 2014 3:51 PM
  • User46609 posted

    On your Xamarin Android project: Project Option > Build > Android Build > Advanced (tab)

    Set Java Heap Size to 1G

    Thursday, January 8, 2015 11:30 AM
  • User60594 posted

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

    Thursday, April 16, 2015 6:26 PM
  • User39666 posted

    Sorry,I use VS2013 IDE and have same problem,
    how to Set Java Heap Size to 1G in VS2013?

    Friday, April 17, 2015 2:22 AM
  • User79112 posted

    @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)
    Friday, April 17, 2015 11:09 AM
  • User77850 posted

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

    Tuesday, May 26, 2015 2:25 PM
  • User100555 posted

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

    Thursday, June 18, 2015 9:40 AM
  • User158766 posted

    Thanks, that fixed my problem.

    Sunday, September 20, 2015 10:16 AM
  • User199302 posted

    same problem... fixed! thanks

    Friday, February 26, 2016 11:32 PM
  • User184899 posted

    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

    Sunday, May 1, 2016 3:07 AM
  • User225340 posted

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

    Sunday, May 15, 2016 2:23 AM
  • User225714 posted

    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.

    Wednesday, June 29, 2016 5:15 PM
  • User236567 posted

    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

    Friday, August 19, 2016 5:18 AM
  • User261981 posted

    me too i want help plz

    Saturday, October 1, 2016 2:15 PM
  • User296555 posted

    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.

    Monday, February 26, 2018 11:00 PM