Reputation: 1519
I just created a new Xamarin solution in visual studio. Here is how the solution looks like:
And when I try to build, it shows the following error:
"javac.exe" exited with code 2.
Here is the error logs in output window:
1>------ Rebuild All started: Project: App2.Droid, Configuration: Debug Any CPU ------ 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(605,2): warning : Failed to get the Java SDK version. Found java version "9.0.1" 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(605,2): warning : Java(TM) SE Runtime Environment (build 9.0.1+11) 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(605,2): warning : Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode) 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(605,2): warning : but this does not seem to contain a valid version number. 1> App2.Droid -> C:\Users\abaig\documents\visual studio 2015\Projects\App2\App2\App2.Droid\bin\Debug\App2.Droid.dll 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1914,3): error MSB6006: "javac.exe" exited with code 2. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Any Idea what could be wrong?
Upvotes: 2
Views: 6732
Reputation: 1286
On a Mac with java sdk jdk-9.0.1.jdk installed using visual studio I got this build error:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error MSB6006: "javac" exited with code 2. (MSB6006) (ProjectX.Droid)
I installed java sdk jdk1.8.0_151.jdk (did not un-installed jdk 9) and changed java sdk (jdk) Location (preferences > sdk location > andriod > locations) to /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
...then I have no build errors
Upvotes: 1
Reputation: 1519
Here is what solved this problem.
While setting up Xamarin I had installed Java SE Development Kit 9. Now I've uninstalled it and instead I have installed Java SE Development Kit 8. After installing Java SE Development Kit 8, all I did is, update the JDK location in Android Settings, so that it now points to JDK v8. See below:
Upvotes: 1
Reputation: 1486
try to enable your multidex, go to yourandroidproject > rightclick > properties > Android options and click enable Multi-Dex
Upvotes: 2