Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android: java.exe exited with Code 2 -- MultiDex enabled

After the most recent update (Xamarin.Android.Support libraries, V28.0.0, Build tools 28.0.3), every build is failing with

"java.exe" exited with Code 2

I had previously enabled Multi-Dex to get rid of this issue, and that has worked without a problem until now. I also tried re-enabling ProGuard, and following all of the steps from this answer, including the change to MainDexClasses.bat.

There are a couple of new warnings, but I haven't been able to work out whether or not they are causing the new problem:

CREATEMULTIDEXMAINDEXCLASSLIST: warning : can't write resource [META-INF/maven/com.squareup.okio/okio/pom.xml] (Duplicate zip entry [okio.jar:META-INF/maven/com.squareup.okio/okio/pom.xml])

CREATEMULTIDEXMAINDEXCLASSLIST: warning : can't write resource [META-INF/maven/com.squareup.okio/okio/pom.properties] (Duplicate zip entry [okio.jar:META-INF/maven/com.squareup.okio/okio/pom.properties])

UPDATE: It looks like this is a bug that has crept in with the V28 SDK. There is a repro at https://github.com/SpiegelSoft/Repro, and I have created an issue at https://github.com/xamarin/xamarin-android/issues/2565

If anyone can find any neat workarounds, I will be very grateful.

like image 668
Rob Lyndon Avatar asked Dec 18 '18 12:12

Rob Lyndon


1 Answers

I had this issue and Fix for me was:

  1. Close Project
  2. Delete bin and obj folders from PCL/Shared Project and all other platforms including Android
  3. Open project
  4. Rebuild
like image 62
user3322401 Avatar answered Oct 14 '22 08:10

user3322401