1
votes

I'm building a Xamarin binding for a Java SDK. I managed to build it and deploy it on a device. However, I had to add more dependencies to the library and reached the max 64k methods authorized by the Dalvik Executable. I decided to enable Multi-Dex via the Android Options property of my application to bypass that limit.

I now get an error when building the app and I can't find any reference of it on the web.

Here is a sample of the Build Output:

3> C:\Program Files\Java\jdk1.8.0_181\bin\java.exe -Xmx1G -jar C:\Users\witol.nuget\packages\xamarin-android-d8-build\0.2.1\build\d8.jar --debug --multi-dex --main-dex-list=obj\Debug\MonoAndroid80\multidex.keep --output obj\Debug\MonoAndroid80\android\bin C:\Users\witol\source\repos\VoxeetBinding4\VoxeetBinding4Sample2\obj\Debug\MonoAndroid80\android\bin\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.0\mono.android.jar" "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\android-support-multidex.jar" obj\Debug\MonoAndroid80\lp\0\jl\eventbus-3.0.0.jar obj\Debug\MonoAndroid80\lp\10\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\11\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\12\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\13\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\14\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\15\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\16\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\17\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\18\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\19\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\20\jl\public-sdk-1.1.7.1.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__adapter-rxjava-2.1.0.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__guava-19.0.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__jackson-annotations-2.7.0.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__jackson-core-2.7.2.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__jackson-databind-2.7.2.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__logging-interceptor-3.4.0-RC1.jar obj\Debug\MonoAndroid80\lp\20\jl__reference__rxandroid-1.2.1.jar obj\Debug\MonoAndroid80\lp\20\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\21\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\22\jl\classes.jar obj\Debug\MonoAndroid80\lp\23\jl\classes.jar obj\Debug\MonoAndroid80\lp\24\jl\retrofit-2.1.0.jar obj\Debug\MonoAndroid80\lp\25\jl\okhttp3.jar obj\Debug\MonoAndroid80\lp\26\jl\rxjava-1.1.8.jar obj\Debug\MonoAndroid80\lp\27\jl\nv-websocket-client-2.3.jar obj\Debug\MonoAndroid80\lp\27\jl__reference__hamcrest-core-1.3.jar obj\Debug\MonoAndroid80\lp\27\jl__reference__junit-4.12.jar obj\Debug\MonoAndroid80\lp\28\jl\classes.jar obj\Debug\MonoAndroid80\lp\29\jl\classes.jar obj\Debug\MonoAndroid80\lp\3\jl\arch-core-common.jar obj\Debug\MonoAndroid80\lp\30\jl\okio.jar obj\Debug\MonoAndroid80\lp\31\jl\classes.jar obj\Debug\MonoAndroid80\lp\4\jl\arch-lifecycle-common.jar obj\Debug\MonoAndroid80\lp\5\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\6\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\8\jl\bin\classes.jar obj\Debug\MonoAndroid80\lp\9\jl\bin\classes.jar (TaskId:283)

3> Compilation failed: Unknown option: --multi-dex (TaskId:283)

3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2521,3): error MSB6006: "java.exe" exited with code 1.

Apparently the java executable doesn't recognize the "--multid-dex" option.

What I've tried:

  • Update my Android BuildTools
  • Dowload the newest ProGuard version from SourceForge
  • Try different MinSdkVersion (19, 21)
  • Create a new Android App Project

Targeting API Level 26 - Android 8.0 (Oreo)

MinSDkVersion is now at Api Level 22 - Android 5.1 (Lolipop)

UPDATE: If I create another blank Android App project and enable the Multi-Dex option it builds correctly.

1

1 Answers

0
votes

For reference:

I installed a NuGet package "xamarin-android-d8-build" which adds d8 compiler support for Xamarin.Android. That's why it wasn't recognizing the "--multi-dex" option.