Bug 38693 - Call of mainDexClasses.bat does not produce records in multidex.keep
Summary: Call of mainDexClasses.bat does not produce records in multidex.keep
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: unspecified
Hardware: PC Windows
: Low normal
Target Milestone: master
Assignee: dean.ellis
URL:
: 55268 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-11 20:05 UTC by Mikhail Melnik
Modified: 2018-01-12 22:19 UTC (History)
4 users (show)

Tags: XATriaged
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mikhail Melnik 2016-02-11 20:05:49 UTC
Some time ago I found that multidex option doesn't work as expected: https://forums.xamarin.com/discussion/57485/multiple-issues-with-library-project-and-multidex and shortly after that identified that root cause is a way how batch file parameters are sent and processed.

I assume it is working fine on OSX and *nix but on Windows there are two issues: on Xamarin side MSBuild generates an incorrect input parameter wrapping every path in unnecessary single quotes and on SDK side mainDexClasses.bat wraps some variables in unnecessary double quotes too.

Here is a part from original mainDexClasses.bat:

```
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 my workaround where I clean input and modify subsequent calls:

```
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
```
Comment 1 ian 2016-02-18 05:34:17 UTC
Great find. I reported this months ago and haven't really seen any progress on it, this is the first actual viable workaround I've seen.
Comment 2 dean.ellis 2017-04-26 13:09:47 UTC
a PR is up which should help address this issue [1].
It completely replaces the google tooling in this area.


[1] https://github.com/xamarin/xamarin-android/pull/575
Comment 3 dean.ellis 2017-05-03 13:48:04 UTC
Fixed in Xamarin-android/master/6829b7d1

We stopped using the .bat file in favour of making the calls ourselves.
Comment 4 Jonathan Pryor 2018-01-12 22:19:57 UTC
*** Bug 55268 has been marked as a duplicate of this bug. ***