Error after Enable Multi-Dex in Xamarin Android

3.9k views Asked by At

While creating a Xamarin Android application, after adding the reference to Infragistics Chart control and the Google Play services, we had to enable the 'Enable Multi-Dex' property to true (Since the app hit the dex method limit of 65K). We are getting an error

..\CREATEMULTIDEXMAINDEXCLASSLIST: Error: Expecting class path
separator ';' before
'\Android\android-sdk\build-tools\21.1.1\lib\shrinkedAndroid.jar' in
argument number 8

I am using Xamarin Studio Version 5.9 (build 431) Xamarin.Android Version: 5.1.0

Please help to fix this Issue in Xamarin.

6

There are 6 answers

0
xleon On

For those who donĀ“t want to change the Android SDK actual location plus ANDROID_HOME env variable, a simple link is enough:

mklink /D "C:\android-sdk" "C:\Program Files (x86)\Android\android-sdk"
0
KiwiSunGoddess On

For future reference, there is also a bug if you have JDK 1.8 installed..

See this thread https://bugzilla.xamarin.com/show_bug.cgi?id=44013

Unfortunately the actual bug is inaccessible to general public.. https://bugzilla.xamarin.com/show_bug.cgi?id=42669

1
Daniele D. On

I'm facing this problem any time I make an update that change or install a new build-tools folder. So I decided to store the solution here for myself and for whom could benefit from this solution.

Some of the bugzilla link in other solutions or comments are not accessible from anyone. The reason for this is an issue with the Android SDK on Windows machines. The following fix needs to be applied to the build server and developer machines:

  1. The fix is to adjust the mainDexClasses.bat in the Android SDK. Search for this file and apply the fix to all instances. The first thing is locate the folder android-sdk and sub build-tools. My path is for example C:\Users\YOURUSERNAME\AppData\Local\Android\android-sdk\build-tools\ check inside the folders named with the version number like xx.x.x (e.g. 24.0.1)
  2. So inside the mainDexClasses.bat file locate the following block of text:

if DEFINED output goto redirect
call "%java_exe%" -Djava.ext.dirs="%frameworkdir%" com.android.multidex.MainDexListBuilder "%disableKeepAnnotated%" "%tmpJar%" "%params%"
goto afterClassReferenceListBuilder
:redirect call "%java_exe%" -Djava.ext.dirs="%frameworkdir%" com.android.multidex.MainDexListBuilder "%disableKeepAnnotated%" "%tmpJar%" "%params%" 1>"%output%"
:afterClassReferenceListBuilder

And replace with:

SET params=%params:'=%
if DEFINED output goto redirect
call "%java_exe%" -Djava.ext.dirs="%frameworkdir%" com.android.multidex.MainDexListBuilder %disableKeepAnnotated% "%tmpJar%" %params%
goto afterClassReferenceListBuilder
:redirect call "%java_exe%" -Djava.ext.dirs="%frameworkdir%" com.android.multidex.MainDexListBuilder %disableKeepAnnotated% "%tmpJar%" %params% 1>"%output%"
:afterClassReferenceListBuilder

  1. Clean and build again.
0
Mousskoff On

I had the same problem. To resolve it you must go to the properties of your project and in the option Android Options in packaging you disable Multi-Dex. And in the debugger option choose Xamarin or not Microsoft. I think that it resolves your problem.

0
Vimal Kotadia On

Please Put your SDK into where is available Enough space and then put your jar or dll file there it will worked.

0
KMB On

We had the same problem on our build server, and we've had to move the Android SDK to a path with no spaces e.g. C:\android-sdk\...

Obviously we needed to update the ANDROID_HOME environment variable to the new path, and set the SDK paths in Xamarin Studio and Visual Studio.

This has solved the problem for us.