Bug 33554 - monodroid error XA0000: Reason: An element with the same key already exists in the dictionary
Summary: monodroid error XA0000: Reason: An element with the same key already exists i...
Alias: None
Product: Android
Classification: Xamarin
Component: Pre-release ()
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: 5.1.6 (C5SR4)
Assignee: dean.ellis
: 35069 ()
Depends on:
Reported: 2015-09-01 15:20 UTC by Philipp
Modified: 2015-10-20 04:44 UTC (History)
4 users (show)

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:

Description Philipp 2015-09-01 15:20:29 UTC
When switching from the current stable (3.11.837) to the current beta channel, I cannot build my solution anymore:
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1866,3): 
Reason: An element with the same key already exists in the dictionary

The project is pretty complex involving several Java libraries (jar, zip, with and without native libraries). It's available on https://keepass2android.codeplex.com/SourceControl/latest. I haven't found the time to reduce to a minimal sample.
Maybe you can find the issue by looking at the changes between the two versions.
Comment 1 Jonathan Pryor 2015-09-01 15:36:56 UTC
Please provide diagnostic build output:

Comment 4 Jonathan Pryor 2015-09-02 14:50:21 UTC
@Philipp: Could you please provide a "prebuilt" copy of the project, or build instructions? A checkout/download doesn't build:

> CSC: error CS2001: Source file `Io/DropboxFileStorageKeys.cs' could not be found
> error : At least one input jar must be specified


For example, the Kp2aKeyboardBinding project wants "..\java\KP2ASoftKeyboard2\java\project.zip", which doesn't exist, and there are no instructions on how to create that file, and the "obvious" (?) attempt to create it fails:

> cd java/KP2ASoftKeyboard2
> android  update project -p .
> ant debug
>     [javac] /Volumes/Seagate4TB/work/bxc-33554/src/java/KP2ASoftKeyboard2/java/src/keepass2android/softkeyboard/LatinKeyboardBaseView.java:425: error: constant expression required
>     [javac]             case R.styleable.LatinKeyboardBaseView_keyBackground:
> ...
Comment 5 Philipp 2015-09-02 17:21:08 UTC
@JonP: thanks for looking into this.

I have pushed all relevant binary files (project.zips, .so files) to the repo. After pulling the latest version, you should only need to 
* rename src\Kp2aBusinessLogic\Io\DropboxFileStorageKeysDummy.cs to DropboxFileStorageKeys.cs
* execute src\keepass2android\UseManifestNet.bat

I have installed the latest Xamarin version on a machine that has never seen Xamarin or even Android SDK before. Getting the same issue.

Any workaround would be great, as my app is currently published with the current stable version which seems to have a bug from Mono regarding GZip, so I'd really appreciate if I could build with the latest version.
Comment 6 dean.ellis 2015-09-03 11:55:32 UTC

Thanks for the instructions, I have successfully replicated the issue locally and I am working on a fix. Not sure which release it will be in next but I'll try to get it out asap
Comment 7 dean.ellis 2015-09-08 10:09:44 UTC
Fixed in monodroid/master/a4ba096e
Comment 8 Peter Collins 2015-09-08 18:40:27 UTC
I was able to reproduce this and then verify the fix on Windows using the solution provided against XVS 3.11 (monodroid-5.1-series / 7adccb2.
Comment 9 dean.ellis 2015-10-20 04:44:10 UTC
*** Bug 35069 has been marked as a duplicate of this bug. ***