Bug 56820 - Xamarin.Android.Common.targets(3,3): Error MSB6006: “java” exited with code 2.
Summary: Xamarin.Android.Common.targets(3,3): Error MSB6006: “java” exited with code 2.
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-05-24 23:47 UTC by James Clancey
Modified: 2017-06-23 18:39 UTC (History)
2 users (show)

See Also:
Tags: bb
Is this bug a regression?: ---
Last known good build:


Description James Clancey 2017-05-24 23:47:10 UTC
We should give a better error. when users encounter: Xamarin.Android.Common.targets(3,3): Error MSB6006: “java” exited with code 2.

typically caused by going over the dalvik method limit. Point them to a doc telling them to reduce dependencies or enable mutlidex
Comment 1 Jon Douglas [MSFT] 2017-06-23 18:16:54 UTC
I believe this issue can be solved by resolving the following bug first:


Going back to external programs giving an exit code of 0-255, we should be returning an error to MSBuild's Error List that contains actionable steps for the user. Typically to find these actionable steps, the user has to enable diagnostic build output. Here's an example of dx.jar failing similar to what Clancey is reporting:


Thus the error message:

1>  trouble writing output: Too many field references: 67288; max is 65536. (TaskId:260)
1>  You may try using --multi-dex option. (TaskId:260)

Should be returned to the user to inform them on an actionable step. We could potentially reword this message to say "Enable Multidex in your Android Options" which they actually have control over.

Note You need to log in before you can comment on or make changes to this bug.