I have built an android app using xamarin in VS2015. I was able to release first version of app on google play service.
The other day, I tried to fix the problems and modified some UI, added some xml files and activities.
But I got the error java.exe exited with code 2 in debug mode when I build the project whereas building was successful in release mode.
I tried changing HeapSize 1G to 2G found no difference. I tried to enable ProGuard but found disabled by default. I went through enabling MultiDex, it lead me another error that file not found error. I even tried deleting bin and obj folder and rebuilt again but no luck!
This is the error
Severity Code Description Project File Line Suppression State
Error "java.exe" exited with code 2. WebSchoolAndroid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 2152
and in line 2152 I have
<!-- Compile java code to dalvik -->
<CompileToDalvik
Condition="'$(UseJackAndJill)'!='True'"
DxJarPath="$(DxJarPath)"
JavaToolPath="$(JavaToolPath)"
JavaMaximumHeapSize="$(JavaMaximumHeapSize)"
JavaOptions="$(JavaOptions)"
ClassesOutputDirectory="$(IntermediateOutputPath)android\bin\classes"
ToolPath="$(DxToolPath)"
ToolExe="$(DxToolExe)"
UseDx="$(UseDx)"
MultiDexEnabled="$(AndroidEnableMultiDex)"
MultiDexMainDexListFile="$(_AndroidMainDexListFile)"
JavaLibrariesToCompile="@(_JavaLibrariesToCompileForAppDx)"
OptionalObfuscatedJarFile="$(IntermediateOutputPath)proguard\__proguard_output__.jar"
/>
From Diagnostic Output
C:\Program Files (x86)\Java\jdk1.8.0_101\\bin\java.exe -Xmx1G -jar C:\Users\user\AppData\Local\Xamarin\Universal\AndroidSDK\build-tools\24.0.3\\lib\dx.jar --no-strict --dex --output=obj\Debug\android\bin obj\Debug\android\bin\classes "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v6.0\mono.android.jar" obj\Debug\__library_projects__\PdfViewBinding\library_project_imports\bin\android-pdfview.jar obj\Debug\__library_projects__\PhotoViewBinding\library_project_imports\bin\photoview.jar obj\Debug\__library_projects__\Square.OkHttp\library_project_imports\okhttp-2.4.0.jar obj\Debug\__library_projects__\Square.OkIO\library_project_imports\okio-1.5.0.jar obj\Debug\__library_projects__\Square.Picasso\library_project_imports\picasso-2.5.2.jar obj\Debug\__library_projects__\UrlImageViewHelper\library_project_imports\bin\classes.jar obj\Debug\__library_projects__\WebSchoolAndroid.Bindings\library_project_imports\skyepub.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Animated.Vector.Drawable\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Compat\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Compat\24.2.1\embedded\libs\internal_impl-24.2.1.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Core.UI\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Core.UI\24.2.1\embedded\libs\internal_impl-24.2.1.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Core.Utils\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Core.Utils\24.2.1\embedded\libs\internal_impl-24.2.1.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Design\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Fragment\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Fragment\24.2.1\embedded\libs\internal_impl-24.2.1.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Media.Compat\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Media.Compat\24.2.1\embedded\libs\internal_impl-24.2.1.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.v4\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.v7.AppCompat\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.v7.CardView\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.v7.RecyclerView\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Android.Support.Vector.Drawable\24.2.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Firebase.Common\9.6.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Firebase.Iid\9.6.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.Firebase.Messaging\9.6.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Base\9.6.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Basement\9.6.1\embedded\classes.jar C:\Users\user\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Tasks\9.6.1\embedded\classes.jar (TaskId:294)
1> (TaskId:294)
1> trouble writing output: Too many field references: 65549; max is 65536. (TaskId:294)
1> You may try using --multi-dex option. (TaskId:294)
1> References by package: (TaskId:294)
1> 2 android.accounts (TaskId:294)
1> 29 android.app (TaskId:294)
1> 1 android.content (TaskId:294)
1> 32 android.content.pm (TaskId:294)
1> 9 android.content.res (TaskId:294)
1> 3 android.database (TaskId:294)
1> 51 android.graphics (TaskId:294)
1> 2 android.media (TaskId:294)
1> 1 android.media.browse (TaskId:294)
1> 2 android.net (TaskId:294)
1> 17 android.os (TaskId:294)
1> 3 android.print (TaskId:294)
1> 1 android.provider (TaskId:294)
1> 8 android.runtime (TaskId:294)
1> 2410 android.support.compat (TaskId:294)
1> 2410 android.support.coreui (TaskId:294)
1> 2410 android.support.coreutils (TaskId:294)
1> 2410 android.support.design (TaskId:294)
1> 58 android.support.design.internal (TaskId:294)
1> 679 android.support.design.widget (TaskId:294)
1> 2410 android.support.fragment (TaskId:294)
1> 2563 android.support.graphics.drawable (TaskId:294)
1> 2410 android.support.graphics.drawable.animated (TaskId:294)
1> 2410 android.support.mediacompat (TaskId:294)
1> 2410 android.support.v4 (TaskId:294)
1> 13 android.support.v4.accessibilityservice (TaskId:294)
1> 17 android.support.v4.animation (TaskId:294)
1> 863 android.support.v4.app (TaskId:294)
1> 111 android.support.v4.content (TaskId:294)
1> 1 android.support.v4.content.pm (TaskId:294)
1> 1 android.support.v4.content.res (TaskId:294)
1> 9 android.support.v4.graphics (TaskId:294)
1> 41 android.support.v4.graphics.drawable (TaskId:294)
1> 4 android.support.v4.hardware.display (TaskId:294)
1> 12 android.support.v4.hardware.fingerprint (TaskId:294)
1> 10 android.support.v4.internal.view (TaskId:294)
1> 350 android.support.v4.media (TaskId:294)
1> 300 android.support.v4.media.session (TaskId:294)
1> 7 android.support.v4.net (TaskId:294)
1> 19 android.support.v4.os (TaskId:294)
1> 63 android.support.v4.print (TaskId:294)
1> 9 android.support.v4.provider (TaskId:294)
1> 55 android.support.v4.text (TaskId:294)
1> 6 android.support.v4.text.util (TaskId:294)
1> 102 android.support.v4.util (TaskId:294)
1> 433 android.support.v4.view (TaskId:294)
1> 137 android.support.v4.view.accessibility (TaskId:294)
1> 8 android.support.v4.view.animation (TaskId:294)
1> 495 android.support.v4.widget (TaskId:294)
1> 397 android.support.v7.app (TaskId:294)
1> 2410 android.support.v7.appcompat (TaskId:294)
1> 2410 android.support.v7.cardview (TaskId:294)
1> 8 android.support.v7.content.res (TaskId:294)
1> 18 android.support.v7.graphics.drawable (TaskId:294)
1> 2410 android.support.v7.recyclerview (TaskId:294)
1> 1 android.support.v7.text (TaskId:294)
1> 2 android.support.v7.transition (TaskId:294)
1> 124 android.support.v7.util (TaskId:294)
1> 77 android.support.v7.view (TaskId:294)
1> 248 android.support.v7.view.menu (TaskId:294)
1> 1398 android.support.v7.widget (TaskId:294)
1> 89 android.support.v7.widget.helper (TaskId:294)
1> 1 android.support.v7.widget.util (TaskId:294)
1> 5 android.text (TaskId:294)
1> 1 android.text.util (TaskId:294)
1> 14 android.util (TaskId:294)
1> 18 android.view (TaskId:294)
1> 8 android.view.accessibility (TaskId:294)
1> 1 android.view.inputmethod (TaskId:294)
1> 5 android.webkit (TaskId:294)
1> 21 android.widget (TaskId:294)
1> 2404 com.google.android.gms (TaskId:294)
1> 20 com.google.android.gms.actions (TaskId:294)
1> 13 com.google.android.gms.ads.identifier (TaskId:294)
1> 36 com.google.android.gms.auth.api.signin (TaskId:294)
1> 6 com.google.android.gms.auth.api.signin.internal (TaskId:294)
1> 2404 com.google.android.gms.base (TaskId:294)
1> 98 com.google.android.gms.common (TaskId:294)
1> 95 com.google.android.gms.common.api (TaskId:294)
1> 41 com.google.android.gms.common.data (TaskId:294)
1> 46 com.google.android.gms.common.images (TaskId:294)
1> 188 com.google.android.gms.common.internal (TaskId:294)
1> 1 com.google.android.gms.common.internal.safeparcel (TaskId:294)
1> 4 com.google.android.gms.common.server (TaskId:294)
1> 12 com.google.android.gms.common.server.converter (TaskId:294)
1> 33 com.google.android.gms.common.server.response (TaskId:294)
1> 63 com.google.android.gms.common.stats (TaskId:294)
1> 22 com.google.android.gms.common.util (TaskId:294)
1> 27 com.google.android.gms.dynamic (TaskId:294)
1> 2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags (TaskId:294)
1> 16 com.google.android.gms.flags.impl (TaskId:294)
1> 6 com.google.android.gms.iid (TaskId:294)
1> 1341 com.google.android.gms.internal (TaskId:294)
1> 5 com.google.android.gms.location.places (TaskId:294)
1> 18 com.google.android.gms.phenotype (TaskId:294)
1> 11 com.google.android.gms.playlog.internal (TaskId:294)
1> 6 com.google.android.gms.security (TaskId:294)
1> 26 com.google.android.gms.signin.internal (TaskId:294)
1> 2452 com.google.android.gms.tasks (TaskId:294)
1> 2435 com.google.firebase (TaskId:294)
1> 2 com.google.firebase.auth (TaskId:294)
1> 2459 com.google.firebase.iid (TaskId:294)
1> 2437 com.google.firebase.messaging (TaskId:294)
1> 2495 com.joanzapata.pdfview (TaskId:294)
1> 8 com.joanzapata.pdfview.model (TaskId:294)
1> 39 com.joanzapata.pdfview.util (TaskId:294)
1> 2492 com.koushikdutta.urlimageviewhelper (TaskId:294)
1> 1131 com.skytree.epub (TaskId:294)
1> 368 com.squareup.okhttp (TaskId:294)
1> 90 com.squareup.okhttp.internal (TaskId:294)
1> 133 com.squareup.okhttp.internal.http (TaskId:294)
1> 1 com.squareup.okhttp.internal.io (TaskId:294)
1> 243 com.squareup.okhttp.internal.spdy (TaskId:294)
1> 11 com.squareup.okhttp.internal.tls (TaskId:294)
1> 347 com.squareup.picasso (TaskId:294)
1> 2401 com.ytechwebschool.droid (TaskId:294)
1> 2 java.io (TaskId:294)
1> 12 java.lang (TaskId:294)
1> 7 java.lang.annotation (TaskId:294)
1> 6 java.net (TaskId:294)
1> 1 java.nio (TaskId:294)
1> 6 java.util (TaskId:294)
1> 4 java.util.concurrent (TaskId:294)
1> 3 java.util.logging (TaskId:294)
1> 2 md5019150c7713b24a447e4fd8c3f76632d (TaskId:294)
1> 2 md5048a04284979bff265231e98628579ce (TaskId:294)
1> 8 md520476b3d730a4692111560b01beafbf5 (TaskId:294)
1> 2 md5205d0916216d138654c77f637ee1cc90 (TaskId:294)
1> 12 md521020641efcec5bf9b0512907b92f249 (TaskId:294)
1> 10 md52335815dbfafa80b49f1a49c2a70d818 (TaskId:294)
1> 4 md526b7ac14cffc1a788e82c7b73f3add08 (TaskId:294)
1> 4 md531f8cc8d4d39b2fa02686ee0eb368905 (TaskId:294)
1> 8 md5471d110c8bb7ff37297374df784c2cee (TaskId:294)
1> 6 md55033ca37c678cdf20c14f110c9bacb80 (TaskId:294)
1> 178 md552b354c3816a29fbb90de6c8f0fdcd19 (TaskId:294)
1> 6 md552b8a35caf489e8e9cc4abcbc24b4c72 (TaskId:294)
1> 2 md55d8049a390a6f59c6033421d9a6a7cb8 (TaskId:294)
1> 18 md55f745489a55c1418869d471d93b5f35b (TaskId:294)
1> 4 md5636a41490577073255dce8c0a20bd415 (TaskId:294)
1> 10 md573df5bf65258bde5f06e24f6fe60f220 (TaskId:294)
1> 4 md5d0344be23ac987695f177aa1dab31949 (TaskId:294)
1> 16 md5de74fe60be74057a72a4e5ed2f8ed880 (TaskId:294)
1> 2 md5e424e6ea239d40c2a27b23ad851f2b02 (TaskId:294)
1> 4 md5ef453142d677b7c0ee97e9e15b9f6cda (TaskId:294)
1> 4 md5fb73fd704f950839995cd69b1931d746 (TaskId:294)
1> 6 mono (TaskId:294)
1> 2 mono.android.accounts (TaskId:294)
1> 12 mono.android.animation (TaskId:294)
1> 29 mono.android.app (TaskId:294)
1> 2 mono.android.bluetooth (TaskId:294)
1> 20 mono.android.content (TaskId:294)
1> 2 mono.android.database.sqlite (TaskId:294)
1> 6 mono.android.drm (TaskId:294)
1> 6 mono.android.gesture (TaskId:294)
1> 2 mono.android.graphics (TaskId:294)
1> 2 mono.android.graphics.drawable (TaskId:294)
1> 8 mono.android.hardware (TaskId:294)
1> 2 mono.android.hardware.display (TaskId:294)
1> 2 mono.android.hardware.input (TaskId:294)
1> 2 mono.android.inputmethodservice (TaskId:294)
1> 6 mono.android.location (TaskId:294)
1> 60 mono.android.media (TaskId:294)
1> 16 mono.android.media.audiofx (TaskId:294)
1> 2 mono.android.media.effect (TaskId:294)
1> 2 mono.android.media.midi (TaskId:294)
1> 2 mono.android.media.session (TaskId:294)
1> 2 mono.android.media.tv (TaskId:294)
1> 2 mono.android.net (TaskId:294)
1> 6 mono.android.net.nsd (TaskId:294)
1> 2 mono.android.net.sip (TaskId:294)
1> 18 mono.android.net.wifi.p2p (TaskId:294)
1> 10 mono.android.os (TaskId:294)
1> 10 mono.android.preference (TaskId:294)
1> 2 mono.android.renderscript (TaskId:294)
1> 6 mono.android.runtime (TaskId:294)
1> 6 mono.android.sax (TaskId:294)
1> 2 mono.android.speech (TaskId:294)
1> 4 mono.android.speech.tts (TaskId:294)
1> 8 mono.android.support.design.widget (TaskId:294)
1> 4 mono.android.support.v4.app (TaskId:294)
1> 4 mono.android.support.v4.content (TaskId:294)
1> 2 mono.android.support.v4.media.session (TaskId:294)
1> 2 mono.android.support.v4.os (TaskId:294)
1> 18 mono.android.support.v4.view (TaskId:294)
1> 4 mono.android.support.v4.view.accessibility (TaskId:294)
1> 12 mono.android.support.v4.widget (TaskId:294)
1> 6 mono.android.support.v7.app (TaskId:294)
1> 32 mono.android.support.v7.widget (TaskId:294)
1> 2 mono.android.text (TaskId:294)
1> 2 mono.android.transition (TaskId:294)
1> 66 mono.android.view (TaskId:294)
1> 4 mono.android.view.accessibility (TaskId:294)
1> 2 mono.android.view.animation (TaskId:294)
1> 2 mono.android.view.textservice (TaskId:294)
1> 8 mono.android.webkit (TaskId:294)
1> 72 mono.android.widget (TaskId:294)
1> 2 mono.com.google.android.gms.common.api (TaskId:294)
1> 2 mono.com.google.android.gms.common.images (TaskId:294)
1> 2 mono.com.google.android.gms.security (TaskId:294)
1> 6 mono.com.google.android.gms.tasks (TaskId:294)
1> 6 mono.com.joanzapata.pdfview.listener (TaskId:294)
1> 6 mono.com.joanzapata.pdfview.util (TaskId:294)
1> 26 mono.com.skytree.epub (TaskId:294)
1> 2 mono.com.squareup.picasso (TaskId:294)
1> 4 mono.java.lang (TaskId:294)
1> 2 mono.java.util (TaskId:294)
1> 2 mono.javax.xml.transform (TaskId:294)
1> 8 mono.org.vudroid.core.events (TaskId:294)
1> 8 mono.uk.co.senab.photoview (TaskId:294)
1> 2 mono.uk.co.senab.photoview.gestures (TaskId:294)
1> 83 okio (TaskId:294)
1> 2 opentk (TaskId:294)
1> 2 opentk.platform.android (TaskId:294)
1> 2 opentk_1_0 (TaskId:294)
1> 2 opentk_1_0.platform.android (TaskId:294)
1> 65 org.vudroid.core (TaskId:294)
1> 6 org.vudroid.core.events (TaskId:294)
1> 6 org.vudroid.core.models (TaskId:294)
1> 3 org.vudroid.core.multitouch (TaskId:294)
1> 1 org.vudroid.core.utils (TaskId:294)
1> 4 org.vudroid.pdfdroid.codec (TaskId:294)
1> 2455 uk.co.senab.photoview (TaskId:294)
1> 16 uk.co.senab.photoview.gestures (TaskId:294)
1> 1 uk.co.senab.photoview.log (TaskId:294)
1> 4 uk.co.senab.photoview.scrollerproxy (TaskId:294)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2152,3): error MSB6006: "java.exe" exited with code 2.
1> DexOutputs: (TaskId:294)
1>Done executing task "CompileToDalvik" -- FAILED. (TaskId:294)
1>Done building target "_CompileToDalvikWithDx" in project "WebSchoolAndroid.csproj" -- FAILED.: (TargetId:147)
Anyone please help me . Thank you in advance.