Question

When following the steps on the Xamarin site for Binding a Java Library to create a binding project for the ArcGIS for Android 10.2.2 I am able to get the project compile. However, when I attempt to deploy and run the project I get the following error:

COMPILETODALVIK : UNEXPECTED TOP-LEVEL error :
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2760)
    at java.util.Arrays.copyOf(Arrays.java:2734)
    at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
    at java.util.ArrayList.add(ArrayList.java:351)
    at com.android.dx.ssa.SsaMethod$2.addToUses(SsaMethod.java:474)
    at com.android.dx.ssa.SsaMethod$2.visitPhiInsn(SsaMethod.java:459)
    at com.android.dx.ssa.PhiInsn.accept(PhiInsn.java:323)
    at com.android.dx.ssa.SsaBasicBlock.forEachInsn(SsaBasicBlock.java:990)
    at com.android.dx.ssa.SsaMethod.forEachInsn(SsaMethod.java:729)
    at com.android.dx.ssa.SsaMethod.buildUseList(SsaMethod.java:452)
    at com.android.dx.ssa.SsaMethod.getUseListForRegister(SsaMethod.java:641)
    at com.android.dx.ssa.SCCP.addUsersToWorklist(SCCP.java:116)
    at com.android.dx.ssa.SCCP.simulateStmt(SCCP.java:538)
    at com.android.dx.ssa.SCCP.simulateBlock(SCCP.java:208)
    at com.android.dx.ssa.SCCP.run(SCCP.java:554)
    at com.android.dx.ssa.SCCP.process(SCCP.java:92)
    at com.android.dx.ssa.Optimizer.runSsaFormSteps(Optimizer.java:160)
    at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:100)
    at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:73)
    at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:273)
    at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:134)
    at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:87)
    at com.android.dx.command.dexer.Main.processClass(Main.java:487)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:422)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
    at com.android.dx.command.dexer.Main.run(Main.java:209)
Was it helpful?

Solution

Update: As Blueberry said, you can now edit this option through Xamarin/Visual Studio editors:

In Xamarin Studio, you can now go to:

Project Option > Build > Android Build > Advanced (tab)

In Visual Studio, you can now go to:

Project Properties > Android Options > Advanced (tab)

You will find Java Heap Size there, which you could set to 1G.

In Xamarin 4.6 and later you can specify the Java Maximum Heap Size (JavaMaximumHeapSize) which allows you to override the "default java heapsize which is sometimes too low to compile some .jar files."

To specify the value, edit the .csproj of the Android project (not the binding project) and add this at the top (where 1G is the value you'd like to set)

<PropertyGroup>
    <JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
</PropertyGroup>

For additional information see this thread on the Xamarin forums.

OTHER TIPS

In Xamarin Studio, you can now go to:

Project Option > Build > Android Build > Advanced (tab)

In Visual Studio, you can now go to:

Project Properties > Android Options > Advanced (tab)

You will find Java Heap Size there, which you could set to 1G.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top