Error after Enable Multi-Dex in Xamarin Android

前端 未结 6 1778
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 04:54

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\' pr

6条回答
  •  温柔的废话
    2021-02-14 05:33

    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.

提交回复
热议问题