Bug 58563 - Build with AndroidExplicitcrunch fails with exception
Summary: Build with AndroidExplicitcrunch fails with exception
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.4 (15.3)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-08-03 10:14 UTC by Michal Dobrodenka
Modified: 2017-08-04 15:32 UTC (History)
3 users (show)

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


Attachments
Build log with exception. (4.17 MB, text/plain)
2017-08-03 10:14 UTC, Michal Dobrodenka
Details


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 INVALID

Description Michal Dobrodenka 2017-08-03 10:14:24 UTC
Created attachment 24002 [details]
Build log with exception.

When I turn AndroidExplicitCrunch on, in hope to get faster builds, build fails on exception:

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Xamarin.Android.Tasks.CopyAndConvertResources.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	TapHome.Android	C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets	1037	

Attaching detailed build log.
Comment 1 Jon Douglas [MSFT] 2017-08-03 15:46:12 UTC
Thank you for the build log! Although this helps identify the issue, we will also need a minimal sample that demonstrates this issue. This can be a File -> New Xamarin.Android which has the minimal items included to reproduce this error. Given it's happening in the "CopyAndConvertResources" Task, it is most likely an issue with parsing resources. Please include the minimal amount of resources in a new project to reproduce this issue.

I believe the resource in question here is: widget_statusicon_ok_icon.png which is technically included twice via the drawable-xhdpi and drawable-sw600dp-xhdpi and thus throws the "An item with the same key has already been added." Perhaps our tooling needs to handle resource qualifiers in a better fashion here. I attempted a similar reproduction, but the tooling seems to work fine(Gets through CopyAndConvertResources and then Crunch).

1>Task "Crunch" (TaskId:126)
1>  Task Parameter:
1>      SourceFiles=
1>          c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable\icon.png
1>          c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable-sw600dp-xhdpi\icon.png
1>          c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable-xhdpi\icon.png
1>          c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\layout\main.xml
1>          c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\values\strings.xml (TaskId:126)
1>  Task Parameter:ToolPath=C:\Users\dougl\AppData\Local\Android\sdk\build-tools\26.0.1\ (TaskId:126)
1>  Crunch Task (TaskId:126)
1>    SourceFiles: (TaskId:126)
1>      c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable\icon.png (TaskId:126)
1>      c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable-sw600dp-xhdpi\icon.png (TaskId:126)
1>      c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable-xhdpi\icon.png (TaskId:126)
1>      c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\layout\main.xml (TaskId:126)
1>      c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\values\strings.xml (TaskId:126)
1>  Crunch Processing : c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable (TaskId:126)
1>    Items : (TaskId:126)
1>      c:\users\dougl\documents\visual studio 2017\Projects\App4\App4\obj\Debug\res\drawable\icon.png (TaskId:126)
1>  Executing c -S C:\Users\dougl\AppData\Local\Temp\ephbflkz.nkz -C C:\Users\dougl\AppData\Local\Temp\bs4chpbb.xnj (TaskId:126)
1>Done executing task "Crunch". (TaskId:126)

So it must be something else. Either way we will need a reproduction to reliably investigate this issue.

Thank you kindly!
Comment 2 Michal Dobrodenka 2017-08-04 08:02:55 UTC
I made app with the same resources and it compile without problems.

So I manually removed all references to Resources in csproj file and then in VS2017 I've added them back.

From now on, no problem with AndroidExplicitCrunch.

But build time is now 15% longer :)

If you want to investigate more, I can attach old project file.
Comment 3 Jon Douglas [MSFT] 2017-08-04 15:32:55 UTC
Setting issue to RESOLVED INVALID based on the self-fix in https://bugzilla.xamarin.com/show_bug.cgi?id=58563#c2

For further investigation into build times, please create a new self contained bugzilla issue with build logs and reproduction projects demonstrating the build increase. Thank you!