0

I'm an android newbie, Installed Xamarin for visual studio, also Installed Android SDK and loads of stuff on there, however I get this error when building:

1>------ Build started: Project: WordSolverO, Configuration: Debug Any CPU ------
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>  WordSolverO -> C:\Users\Elmeri\Documents\WordSolverO\WordSolverO\bin\Debug\WordSolverO.dll
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1868,3): error MSB6006: "javac.exe" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Heres the Xamarin Diagnostics:

[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found:
    Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk).
[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found:
    Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\).
[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found:
    Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk-9.0.1).
[I:Unknown]:              Found Xamarin.Android 7.0.2
[I:Unknown]:              Found Android SDK. API levels: 19, 20, 21, 23
[I:]:                     Tracking android devices started
[D:]:                     TrackDeviceTask got: 
[D:]:                     Tracking avd started
[I:]:                     Got new device list from adb with 0 devices
[D:]:                     avd watcher *.ini path: 'C:\Users\Elmeri\.android\avd'
[D:]:                     avd watcher android path: 'C:\PROGRA~2\Android\ANDROI~1\tools\android.BAT'
[D:]:                     avd watcher: got device list from avd with 1 devices

I've checked the JDK & SDK locations, and theyre fine it seems https://i.stack.imgur.com/LRepB.png

So I have no Idea whats wrong, I dont see any descriptive error here..

Ricochet
  • 11
  • 3
  • Turn up your MSBuild verbosity level to `diagnostic` and you should see the reason why. I would guess the same based on the answer by G.hakim. – Jon Douglas Nov 16 '17 at 16:15
  • https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Diagnostic_MSBuild_Output – Jon Douglas Nov 16 '17 at 16:15

2 Answers2

0

I bet that source of all these problems is DEX 64K limit + old proguard version (in case of multidex enabled). You should upgrade Proguard, according to this topic (procedure has to be performed after each Built-Tools update by SDK-Manager): http://stackoverflow.com/questions/39514518/xamarin-android-proguard-unsupported-class-version-number-52-0

Also check that you have only Java SDK 1.8 installed (remove any 1.7 versions if installed).

PS Don't forget to modify your mainClassesDex.bat (or your app will crash at startup @ Android 4.4 and lower, but work well @ newer versions): http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

FreakyAli
  • 13,349
  • 3
  • 23
  • 63
0

I too faced this issue and later found "javac.exe" exited with code 2 occurs when multidex support is not enabled.

When your app and libraries it references exceed 65,536 methods, you encounter this build error. This means that your app has reached the limit of the Android build architecture.

Please enable the multidex for your android project and you should be able to build and deploy the app. (You can do this by right clicking on Android project, then navigating to project settings/options. In the "build" tab you should have option to enable multidex)

Refer : https://developer.android.com/studio/build/multidex.html