0
votes

Getting this error when trying to run one of the Xamarin.Forms navigation samples from GitHub (MasterDetailsPage)

Severity Code Description Project File Line Suppression State Error java.lang.OutOfMemoryError. Consider increasing the value of $(JavaMaximumHeapSize). Java ran out of memory while executing 'java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.3\lib\dx.jar" --dex --no-strict --output obj\Debug\android\bin \MasterDetailPage\Droid\obj\Debug\android\bin\classes\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.0\mono.android.jar" obj\Debug\lp\0\jl\formsviewgroup.jar obj\Debug\lp\10\jl\bin\classes.jar obj\Debug\lp\11\jl\bin\classes.jar obj\Debug\lp\12\jl\bin\classes.jar obj\Debug\lp\13\jl\bin\classes.jar obj\Debug\lp\14\jl\bin\classes.jar obj\Debug\lp\15\jl\bin\classes.jar obj\Debug\lp\16\jl\bin\classes.jar obj\Debug\lp\17\jl\bin\classes.jar obj\Debug\lp\18\jl\bin\classes.jar obj\Debug\lp\19\jl\bin\classes.jar obj\Debug\lp\20\jl\bin\classes.jar obj\Debug\lp\21\jl\bin\classes.jar obj\Debug\lp\3\jl\arch-core-common.jar obj\Debug\lp\4\jl\arch-lifecycle-common.jar obj\Debug\lp\5\jl\bin\classes.jar obj\Debug\lp\6\jl\bin\classes.jar obj\Debug\lp\8\jl\bin\classes.jar obj\Debug\lp\9\jl\bin\classes.jar C:\Users\me\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Basement\8.4.0\embedded\classes.jar' MasterDetailPageNavigation.Droid

I tried setting android:largeHeap to true in the AndroidManifest.xml

But the error didn't go away I also tried to set the Java Max Heap Size to 1G in the Android Advanced Options under the project properties - the project builds without errors but that's about it, the emulator doesn't launch (or if I have it open nothing happens within it - the app doesn't start)

I read somewhere , that if the emulator doesn't start it means there isn't enough memory for it so it fails silently. I forget exactly the details.

But I have plenty of free RAM on my machine 12GB in total and between 6 - 8 GB avail, when visual studio is running.

1
What emulator are you using? Visual Studio Emulator for Android or Google Emulator?Jon Douglas
@JonDouglas The visual studio emulatorerotavlas

1 Answers

0
votes

The problem occurs while building the app not when running. Open the properties of the Android project and there Android options->Advanced you will find Java Max Heap Size. Using a value of 1G (for one gigabyte) should fix the memory problem.