Could not create the Java Virtual Machine

MoniBhMoniBh ✭✭USMember ✭✭

I am trying to create and .apk file of my project but when I am trying to build the project in release mode, it is giving me these errors:

  1. Could not create the Java Virtual Machine.
  2. Error: A fatal exception has occurred. Program will exit.

I am using google maps in my project. One of my team member is able to generate it from Mac machine but I am using Windows 8.1 and it is giving me errors. I tried increasing the heap size in system variables but it didn't work for me. Can anyone please help me to find out some solution.

Answers

  • MoniBhMoniBh ✭✭ USMember ✭✭

    I found solution on below link and it worked for me :

    https://kb.xamarin.com/customer/portal/articles/1661284-why-does-my-xamarin-forms-maps-android-project-fail-with-compiletodalvik-unexpected-top-level-error-

    I made following settings as suggested for Xamarin Studio

    Right-click the Android project & open the project options.
    Go to "Build -> Android Build -> Advanced"
    In the Java heap size text box enter 1G.
    Rebuild the project.

  • AdamScrogginAdamScroggin ✭✭ USUniversity ✭✭

    Changing the heap to 1G did not work for me.

  • Ram.ShRam.Sh ✭✭ ILUniversity ✭✭

    +1 Changing the heap to 1G did not work for me.

  • SteveResnickSteveResnick ✭✭ USMember ✭✭

    +1 Changing the heap to 1G did not work for me.

  • AdamScrogginAdamScroggin ✭✭ USUniversity ✭✭

    Rebooting my machine sometimes helps. This issue is annoying and I wish they would fix it.

  • elenaorelelenaorel USMember

    "Changing the heap to 1G" worked for me before I upgraded Xamarin studio.
    I have released a few projects without problems in Dec, 3 2015.
    All my projects are broken after uploading a new xamarin studio release.
    Just an example:
    1. I created a new project - picture #1 - OK
    2. Changed Java heap to 1G - as usual
    3. Just added a package "xamarin.googleplayservices.ads" - didn't change anything else - picture#2 -
    java.exe exited with code 1. I didn't add a line of code to the test project.

    "Could not create the Java virtual machine" - it is a hint, but I was not able to figure out the problem.
    Most likely I missed something important.
    Do we have a way to open a ticket with Xamarin?
    Thank you in advance.

  • elenaorelelenaorel USMember

    Heh, Microsoft thanks! I had 30 days to downgrade the windows 10 to windows 8.1. I just did it. All my projects are back with no errors... No more "java.exe exited with code 1" error messages...

  • aunanueaunanue ✭✭ ARMember ✭✭

    I know it's an old thread but in my case I solved by doing this:

    1) Run regedit
    2) Go to HKEY_CURRENT_USER
    3) Select Environment
    4) Add a new String Value and enter _JAVA_OPTIONS for Value name
    5) Enter -Xms256m -Xmx512m for Value data
    6) Reboot computer

  • alaaalshaeralaaalshaer USMember

    I have same problem Changing the heap not help me
    i'm using visual studio xamarin

  • mojtabaZolfagharimojtabaZolfaghari ✭✭ USMember ✭✭
    edited December 2016

    this problem is happened when
    1: update sdk without ndk
    2: new api or tools of sdk come but the user do not upgrade jre to same level
    3: new release of xamarin not need to change heap to 1G but you must update everything about sdk ndk and xamarin version to last

  • mojtabaZolfagharimojtabaZolfaghari ✭✭ USMember ✭✭

    @MoniSrivastava said:
    I am trying to create and .apk file of my project but when I am trying to build the project in release mode, it is giving me these errors:

    1. Could not create the Java Virtual Machine.
    2. Error: A fatal exception has occurred. Program will exit.

    I am using google maps in my project. One of my team member is able to generate it from Mac machine but I am using Windows 8.1 and it is giving me errors. I tried increasing the heap size in system variables but it didn't work for me. Can anyone please help me to find out some solution.

    @AdamScroggin said:
    Changing the heap to 1G did not work for me.

    @aunanue said:
    I know it's an old thread but in my case I solved by doing this:

    1) Run regedit
    2) Go to HKEY_CURRENT_USER
    3) Select Environment
    4) Add a new String Value and enter _JAVA_OPTIONS for Value name
    5) Enter -Xms256m -Xmx512m for Value data
    6) Reboot computer

  • mojtabaZolfagharimojtabaZolfaghari ✭✭ USMember ✭✭

    xamarin not working with sdk 1.9
    old xamarin version work with 1.6.39
    new xamarin version worked with 1.8.51

  • ManojkumarMaliManojkumarMali ✭✭✭ USMember ✭✭✭

    @aunanue said:
    I know it's an old thread but in my case I solved by doing this:

    1) Run regedit
    2) Go to HKEY_CURRENT_USER
    3) Select Environment
    4) Add a new String Value and enter _JAVA_OPTIONS for Value name
    5) Enter -Xms256m -Xmx512m for Value data
    6) Reboot computer

    Thanks @aunanue

  • AuriAuri ✭✭ USMember ✭✭

    In your Android csproj, do the following:

    Make sure you get rid of the following items:

    768MB

    Ensure DebugType is:
    pdbonly

    Good luck!

  • SDKyzeSDKyze Member

    After trying all of the above suggested things, I ended up giving up, uninstalling the JDK and reinstalling it. This fixed my problem. I'm not sure why or what caused it but just in case anyone else has issues.

Sign In or Register to comment.