I was working with Wearable applications using Xamarin.Android. It was working great and I was able to run the application on the emulator and on the actual wearable device itself. The problem started when I was updating the Xamarin.Android.Support and installed the Xamarin.Android.Support.V4 from Nuget. I was able to successfully installed that lib but when I build my application in Visual Studio it just gives me “BUILD FAILED” and that’s it, meaning it doesn’t show any errors at all and I was like what the heck is going on and started to worry about how am I going to fix this without seeing any errors. At first I thought it was a firewall issue or perhaps an anti-virus that was causing the build to fail for some reasons and that didn’t help at all. So I spent hours figuring things out and scratching my head until I found this – Setting MSBuild Verbosity. Configuring the verbosity of MSBuild gives you the verbosity levels of the logger. The following are the options that you can set:
Quiet: only shows the result of your build. Quiet verbosity, which displays a build summary.
Normal: Normal verbosity, which displays errors, warnings, messages with MessageImportance values of High, some status events, and a build summary.Normal: This will show all the targets and its mainly steps.
Minimal: Minimal verbosity, which displays errors, warnings, messages with MessageImportance values of High, and a build summary.
Details: Detailed verbosity, which displays errors, warnings, messages with MessageImportance values of High or Normal, all status events, and a build summary
Diagnostic: Contains all the information that the MSBuild need and produce, it's switches, parameters, prerequisites and etc. The input parameter of the target and task, and also contains the value of the input and output parameter, the detail steps of the task execution. The time execution for each task.
To configure the MSBuild verbosity in Visual Studio 2013 just go to Tools > Options > Project and Solutions > Build and Run. See below for more clearer view:

Then to make sure that the logger captures everything then I needed to set the verbosity to Diagnostic. After that I restarted Visual Studio and open the project again and then do a “build” and Voila! now it gives me logs after building my app. Here’s the portion of the log that caught my attention:
“1>COMPILETODALVIK : UNEXPECTED TOP-LEVEL error :
1> java.lang.OutOfMemoryError: Java heap space (TaskId:131)
1> at java.util.HashMap.resize(HashMap.java:580) (TaskId:131)
1> at java.util.HashMap.addEntry(HashMap.java:879) (TaskId:131)
1> at java.util.HashMap.put(HashMap.java:505) (TaskId:131)
1> at java.util.HashSet.add(HashSet.java:217) (TaskId:131)
1> at com.android.dx.ssa.Dominators.compress(Dominators.java:132) (TaskId:131)
1> at com.android.dx.ssa.Dominators.eval(Dominators.java:160) (TaskId:131)
1> at com.android.dx.ssa.Dominators.run(Dominators.java:207) (TaskId:131)
1> at com.android.dx.ssa.Dominators.make(Dominators.java:90) (TaskId:131)
1> at com.android.dx.ssa.DomFront.run(DomFront.java:86) (TaskId:131)
1> at com.android.dx.ssa.SsaConverter.placePhiFunctions(SsaConverter.java:297) (TaskId:131)
1> at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:51) (TaskId:131)
1> at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98) (TaskId:131)
1> at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72) (TaskId:131)
1> at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297) (TaskId:131)
1> at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137) (TaskId:131)
1> at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93) (TaskId:131)
1> at com.android.dx.command.dexer.Main.processClass(Main.java:729) (TaskId:131)
1> at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) (TaskId:131)
1> at com.android.dx.command.dexer.Main.access$300(Main.java:82) (TaskId:131)
1> at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) (TaskId:131)
1> at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) (TaskId:131)
1> at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) (TaskId:131)
1> at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) (TaskId:131)
1> at com.android.dx.command.dexer.Main.processOne(Main.java:632) (TaskId:131)
1> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) (TaskId:131)
1> at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279) (TaskId:131)
1> at com.android.dx.command.dexer.Main.run(Main.java:245) (TaskId:131)
1> at com.android.dx.command.dexer.Main.main(Main.java:214) (TaskId:131)
1> at com.android.dx.command.Main.main(Main.java:106) (TaskId:131)
1> The command exited with code 3. (TaskId:131)
1>Done executing task "CompileToDalvik" -- FAILED. (TaskId:131)”
Having that response from the log allows me to easily troubleshoot the issue, so I then run away and asked Google about it
.
The fix was to add this section in your .csproj file:
<PropertyGroup>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
</PropertyGroup>
That will let Java allocate enough memory to complete your build.
That’s it! I hope someone find this post useful!