I upgraded my android sdk api version from 27 to 28 and started getting the "java.exe" exited with code 2
while compiling a build.
Output:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2667,3): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="SQLitePCLRaw.batteries_v2" culture="neutral" publicKeyToken="8226ea5df37bcae9" /><bindingRedirect oldVersion="0.0.0.0-1.1.13.388" newVersion="1.1.13.388" /></dependentAssembly></assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="SQLitePCLRaw.core" culture="neutral" publicKeyToken="1488e028ca7ab535" /><bindingRedirect oldVersion="0.0.0.0-1.1.13.388" newVersion="1.1.13.388" /></dependentAssembly></assemblyBinding>
1>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [__reference__commons-io-2.4.jar:META-INF/LICENSE.txt])
1>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [__reference__commons-io-2.4.jar:META-INF/NOTICE.txt])
1>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [__reference__commons-lang-2.6.jar:META-INF/LICENSE.txt])
1>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [__reference__commons-lang-2.6.jar:META-INF/NOTICE.txt])
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2610,3): error MSB6006: "java.exe" exited with code 2.
I am not able to find out the root cause.
Edit
I have multidex enabled in my app but still I am having the same issue.
I found the answer to my question. The answer isnt that great but it works. I was using visual studio 2017 and it had some problem with android 9. I updated it to visual studio 2019 and the app started building properly.