Xamarin Android and Visual Studio Build Failed With no Errors

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 began when I was updating the Xamarin.Android.Support and installed the Xamarin.Android.Support.V4 from Nuget. I was able to successfully install that library but when I built my application in Visual Studio it just gave 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? I began to worry about how 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 that displays a build summary.

Normal: Normal verbosity that 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 that displays errors, warnings, messages with MessageImportance values of High and a build summary.

Details: Detailed verbosity that 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 needs and produces, its switches, parameters, prerequisites and so on. The input parameter of the target and task and also contains the value of the input and output parameter, the detailed procedure of the task execution and 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 the following for a clearer view.



Then to ensure that the logger captures everything then I had to set the verbosity to Diagnostic. Then I restarted Visual Studio and opened the project again and then did 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. 1 > COMPILETODALVIK: UNEXPECTED TOP - LEVEL error: 1 > java.lang.OutOfMemoryError: Java heap space(TaskId: 131)  
  2. 1 > at java.util.HashMap.resize(HashMap.java: 580)(TaskId: 131)  
  3. 1 > at java.util.HashMap.addEntry(HashMap.java: 879)(TaskId: 131)  
  4. 1 > at java.util.HashMap.put(HashMap.java: 505)(TaskId: 131)  
  5. 1 > at java.util.HashSet.add(HashSet.java: 217)(TaskId: 131)  
  6. 1 > at com.android.dx.ssa.Dominators.compress(Dominators.java: 132)(TaskId: 131)  
  7. 1 > at com.android.dx.ssa.Dominators.eval(Dominators.java: 160)(TaskId: 131)  
  8. 1 > at com.android.dx.ssa.Dominators.run(Dominators.java: 207)(TaskId: 131)  
  9. 1 > at com.android.dx.ssa.Dominators.make(Dominators.java: 90)(TaskId: 131)  
  10. 1 > at com.android.dx.ssa.DomFront.run(DomFront.java: 86)(TaskId: 131)  
  11. 1 > at com.android.dx.ssa.SsaConverter.placePhiFunctions(SsaConverter.java: 297)(TaskId: 131)  
  12. 1 > at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java: 51)(TaskId: 131)  
  13. 1 > at com.android.dx.ssa.Optimizer.optimize(Optimizer.java: 98)(TaskId: 131)  
  14. 1 > at com.android.dx.ssa.Optimizer.optimize(Optimizer.java: 72)(TaskId: 131)  
  15. 1 > at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java: 297)(TaskId: 131)  
  16. 1 > at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java: 137)(TaskId: 131)  
  17. 1 > at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java: 93)(TaskId: 131)  
  18. 1 > at com.android.dx.command.dexer.Main.processClass(Main.java: 729)(TaskId: 131)  
  19. 1 > at com.android.dx.command.dexer.Main.processFileBytes(Main.java: 673)(TaskId: 131)  
  20. 1 > at com.android.dx.command.dexer.Main.access$300(Main.java: 82)(TaskId: 131)  
  21. 1 > at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java: 602)(TaskId: 131)  
  22. 1 > at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java: 284)(TaskId: 131)  
  23. 1 > at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java: 166)(TaskId: 131)  
  24. 1 > at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java: 144)(TaskId: 131)  
  25. 1 > at com.android.dx.command.dexer.Main.processOne(Main.java: 632)(TaskId: 131)  
  26. 1 > at com.android.dx.command.dexer.Main.processAllFiles(Main.java: 510)(TaskId: 131)  
  27. 1 > at com.android.dx.command.dexer.Main.runMonoDex(Main.java: 279)(TaskId: 131)  
  28. 1 > at com.android.dx.command.dexer.Main.run(Main.java: 245)(TaskId: 131)  
  29. 1 > at com.android.dx.command.dexer.Main.main(Main.java: 214)(TaskId: 131)  
  30. 1 > at com.android.dx.command.Main.main(Main.java: 106)(TaskId: 131)  
  31. 1 > The command exited with code 3.(TaskId: 131)  
  32. 1 > Done executing task "CompileToDalvik"--FAILED.(TaskId: 131)”  
Having that response from the log allows me to easily troubleshoot the issue, so I then ran away and asked Google about it.

The fix was to add this section to your .CSPROJ file.
  1. <PropertyGroup>   
  2. <JavaMaximumHeapSize>1G</JavaMaximumHeapSize>   
  3. </PropertyGroup>  
That will let Java allocate enough memory to complete your build.

That's it's. I hope someone finds this article useful.


Similar Articles