One of my android project started to complain with this error when Archiving in Release mode. I used to delete the content of the Archive folder, or change the versionCode in androidmanifest to workaround the error. But this time it does not work.
I also tried after deleting bin/obj/.vs and other use files.
Any clue ?
UPDATE
I worked around it by changing the versionName in androidmanifest. It now does archive fine.
Archive correctly without having to change the versionName.
Fails. See logs.
VS2019 16.1.0 Preview 2.
Also happen with other VS versions.
Xamarin.VisualStudio.TastyPackage|Information|0|Hooked up SDB tracing adapter
Xamarin.VisualStudio.TastyPackage|Information|0|Initialization finished
Xamarin|Information|0|Xamarin - 16.1.0.528-d16-1+3cff8c337
Xamarin.VisualStudio.TastyPackage|Information|0|Hooked up SDB tracing adapter
Xamarin.VisualStudio.TastyPackage|Information|0|Initialization finished
Xamarin.VisualStudio.Android.XamarinAndroidPackage|Warning|0|Initializing Xamarin.VisualStudio.Android.XamarinAndroidPackage
Xamarin.VisualStudio.TastyPackage|Information|0|Hooked up SDB tracing adapter
Xamarin.VisualStudio.TastyPackage|Information|0|Initialization finished
Xamarin.VisualStudio.IOS.XamarinIOSPackage|Warning|0|Initializing Xamarin.VisualStudio.IOS.XamarinIOSPackage.
Xamarin.Inspector|Information|0|Inspector extension loaded
Xamarin.VisualStudio.Android.AndroidVirtualDeviceProvider|Error|0|an error occurred loading avd `Android_Accelerated_x86_Nougat`, the system image does not exists
Xamarin.VisualStudio.Android.AndroidVirtualDeviceProvider|Error|0|an error occurred loading avd `Nexus_5X_API_19`, the system image does not exists
Xamarin.VisualStudio.Progress.ProgressReportService|Information|0|Archiving App Bundle 'AirViewer.Droid'...
Xamarin.VisualStudio.Publishing.ArchiveManager|Error|0|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 Microsoft.VisualStudio.PlatformUI.HierarchyManager.GetHierarchyEvents(IVsHierarchy vsHierarchy)
at Microsoft.VisualStudio.PlatformUI.HierarchyManager.AddItem(HierarchyItem item, HierarchyItem knownParent, Boolean isLoadingSolution)
at Microsoft.VisualStudio.PlatformUI.HierarchyManager.GetHierarchyItemImpl(HierarchyItemIdentity identity, HierarchyItem knownParent)
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.AppendChildren(IVsHierarchy hierarchy, UInt32 itemID, List`1 appendedChildren)
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.FillChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_InternalChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_Children()
at Clide.SolutionExplorerNode.get_Nodes() in E:\A\_work\977\s\src\Clide\Solution\SolutionExplorerNode.cs:line 174
at Clide.ITreeNodeExtensions.<>c.<Traverse>b__1_0(ISolutionExplorerNode x) in E:\A\_work\977\s\src\Clide.Interfaces\Extensions\ITreeNodeExtensions.cs:line 33
at Traverser.<TraverseDepthFirst>d__2`1.MoveNext() in E:\A\_work\977\s\src\Clide.Interfaces\Extensions\Traverser.cs:line 70
at System.Linq.Enumerable.<OfTypeIterator>d__95`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Clide.AndroidClideExtensions.GetAndroidResources(IProjectNode projectNode) in E:\A\_work\2139\s\src\Core\VisualStudio.Android\ProjectSystem\Extensions.cs:line 18
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.CreateParameters(IProjectNode project) in E:\A\_work\2139\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 195
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.ArchiveAsync(IProjectNode project, IProgressReport progress, CancellationToken cancellationToken) in E:\A\_work\2139\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 115
at Xamarin.VisualStudio.Publishing.ArchivableProjectBase.<ArchiveAsync>d__8.MoveNext() in E:\A\_work\2139\s\src\Core\VisualStudio.Publishing\Archival\ArchivableProjectBase.cs:line 30
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.VisualStudio.Publishing.ArchiveManager.<ArchiveAsync>d__14.MoveNext() in E:\A\_work\2139\s\src\Core\VisualStudio.Publishing\Archival\ArchiveManager.cs:line 197
Xamarin.VisualStudio.ProgressReport|Error|0|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 Microsoft.VisualStudio.PlatformUI.HierarchyManager.GetHierarchyEvents(IVsHierarchy vsHierarchy)
at Microsoft.VisualStudio.PlatformUI.HierarchyManager.AddItem(HierarchyItem item, HierarchyItem knownParent, Boolean isLoadingSolution)
at Microsoft.VisualStudio.PlatformUI.HierarchyManager.GetHierarchyItemImpl(HierarchyItemIdentity identity, HierarchyItem knownParent)
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.AppendChildren(IVsHierarchy hierarchy, UInt32 itemID, List`1 appendedChildren)
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.FillChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_InternalChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_Children()
at Clide.SolutionExplorerNode.get_Nodes() in E:\A\_work\977\s\src\Clide\Solution\SolutionExplorerNode.cs:line 174
at Clide.ITreeNodeExtensions.<>c.<Traverse>b__1_0(ISolutionExplorerNode x) in E:\A\_work\977\s\src\Clide.Interfaces\Extensions\ITreeNodeExtensions.cs:line 33
at Traverser.<TraverseDepthFirst>d__2`1.MoveNext() in E:\A\_work\977\s\src\Clide.Interfaces\Extensions\Traverser.cs:line 70
at System.Linq.Enumerable.<OfTypeIterator>d__95`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Clide.AndroidClideExtensions.GetAndroidResources(IProjectNode projectNode) in E:\A\_work\2139\s\src\Core\VisualStudio.Android\ProjectSystem\Extensions.cs:line 18
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.CreateParameters(IProjectNode project) in E:\A\_work\2139\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 195
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.ArchiveAsync(IProjectNode project, IProgressReport progress, CancellationToken cancellationToken) in E:\A\_work\2139\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 115
at Xamarin.VisualStudio.Publishing.ArchivableProjectBase.<ArchiveAsync>d__8.MoveNext() in E:\A\_work\2139\s\src\Core\VisualStudio.Publishing\Archival\ArchivableProjectBase.cs:line 30
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.VisualStudio.Publishing.ArchiveManager.<ArchiveAsync>d__14.MoveNext() in E:\A\_work\2139\s\src\Core\VisualStudio.Publishing\Archival\ArchiveManager.cs:line 197
Xamarin.VisualStudio.Progress.ProgressReportService|Information|0|An item with the same key has already been added.
Xamarin.VisualStudio.Progress.ProgressReportService|Information|0|Failed to create App archive 'AirViewer.Droid'.
I am facing the same issue. Thanks for the workaround!
Had the same issue here with Visual Studio 16.0.3 (Xamarin Android 9.2.3.0). For me, updating the AssemblyVersion and AssemblyFileVersion worked around the issue. After successfully creating a package with the new version numbers, I was able to undo those changes and build a package with the original version numbers again.
I have the same issue, this is driving me crazy.
I tested with VS 2019 16.0.3, and VS 2019 16.1.0 preview 2
Sometimes, when I change AssemblyVersion and AssemblyFileVersion, it works, but when I have the error, it is very timefull to change and test it.
Is there a way to reset Archive Manager Keys ?
I'm facing same problem. The work around not work for me. Switch back to VS2017 15.9.11 and the process done. I wonder if it's VS 2019 error?
Same issue here. It seems so randomly work sometimes, but most of the time it does not.
For information, this error is still here with VS 2019 preview 3
Same thing for me with 16.0.3, I switch back to vs2017, no problems there.
Same for me on 16.0.3, and the workaround won't work for me either :(
Thanks for the report! This issue is under investigation on Visual Studio Developer Community in:
I would recommend to vote on the issue that best matches your scenario to help the team with extra data about the affected users, and I would also recommend to follow the item to be notified about additional updates and the resolution. I will also update this GitHub issue when the Developer Community item for Visual Studio 2109 version 16.1 Preview has any updates from the team about a workaround or a released fix. In the mean time, I will close this GitHub issue to direct further discussion onto the Developer Community items. Thanks again!
The 1st link is my report too lol ;) But i prefer github as email notifications are working.
I found the solution !!
Tools > Options > Xamarin > Archives Location
If the path does not ends with a \ it fails to archive. Just add a \ at the end.
A microsoft developer is not used to Path.Combine ?!!!
Adding a / did'nt help in my case, I did it, closed VS, delete all obj/bin but I still can't Archive. Also unloading the iOS Project as suggested by MS did'nt help, but VS2017 have no problem doing it, with or with slash at the end of the archive path. https://developercommunity.visualstudio.com/content/problem/556205/failed-to-create-app-archive-an-item-with-same-key.html
Adding \ and rebuilding solution solve the problem, thanks
It's not a / its a \ !!
Comments are appearing in wrong order now ? Wtf...
Adding a '\' is not better for me...
On VS 2019 preview 3
This was the fix for me as well, adding a trailing backslash to the path
it was C:\Users\SRI38\AppData\Local\Xamarin\Mono for Android\Archives
and i just modded it to C:\Users\SRI38\AppData\Local\Xamarin\Mono for Android\Archives\for it to work and archive successfully
also using developer community to find a solution gives me headaches, github is much nicer(and easier to search for)
@softlion's solution worked for me ultimately, but I had to do a couple of extra steps (I suspect because my %AppData%\..\Local\Xamarin\Mono for Android\Archives directory was empty):
%AppData%\..\Local\Xamarin\Mono for Android\Archivesbin and objBefore I did the other steps the Tools > Options > Xamarin > Archives Location input disappeared from the GUI, and I still got the exception when archiving.
In my case nothing of that helps

No, I will give it a try …..
Von: Karan Harsh Wardhan [mailto:[email protected]]
Gesendet: Samstag, 11. Mai 2019 09:46
An: xamarin/xamarin-android xamarin-android@noreply.github.com
Cc: TFreudi1 TFreudi1@gmx.de; Mention mention@noreply.github.com
Betreff: Re: [xamarin/xamarin-android] Archiving failed: An item with the same key has already been added (#3063)
@TFreudi1 https://github.com/TFreudi1 are you running VS as administrator?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/xamarin/xamarin-android/issues/3063#issuecomment-491488918 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABEFA2IFU453GEGEYCHZMC3PUZ2S5ANCNFSM4HKRZ2AA . https://github.com/notifications/beacon/ABEFA2KMTVVGUAA43LEF2SDPUZ2S5A5CNFSM4HKRZ2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVFYNFQ.gif
The backlash helped me. It was archiving for ages :D. But manually opening manifest and changing the version numbers to something and back which they needed to be helped me also. Manifest did not even notice it was changed, but the archieve process worked after that
Lähetetty iPhonesta
TFreudi1 notifications@github.com kirjoitti 11.5.2019 kello 11.18:
No, I will give it a try …..
Von: Karan Harsh Wardhan [mailto:[email protected]]
Gesendet: Samstag, 11. Mai 2019 09:46
An: xamarin/xamarin-android xamarin-android@noreply.github.com
Cc: TFreudi1 TFreudi1@gmx.de; Mention mention@noreply.github.com
Betreff: Re: [xamarin/xamarin-android] Archiving failed: An item with the same key has already been added (#3063)@TFreudi1 https://github.com/TFreudi1 are you running VS as administrator?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/xamarin/xamarin-android/issues/3063#issuecomment-491488918 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABEFA2IFU453GEGEYCHZMC3PUZ2S5ANCNFSM4HKRZ2AA . https://github.com/notifications/beacon/ABEFA2KMTVVGUAA43LEF2SDPUZ2S5A5CNFSM4HKRZ2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVFYNFQ.gif—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Running as Administrator also did’nt help. And raising Versionnumber + Versionname also did’nt help.
Is there any German user whom adding the backslash helped ? I’m a bit afraid that also the language plays a role.
Von: Evige [mailto:[email protected]]
Gesendet: Samstag, 11. Mai 2019 10:24
An: xamarin/xamarin-android xamarin-android@noreply.github.com
Cc: TFreudi1 TFreudi1@gmx.de; Mention mention@noreply.github.com
Betreff: Re: [xamarin/xamarin-android] Archiving failed: An item with the same key has already been added (#3063)
The backlash helped me. It was archiving for ages :D. But manually opening manifest and changing the version numbers to something and back which they needed to be helped me also. Manifest did not even notice it was changed, but the archieve process worked after that
Lähetetty iPhonesta
TFreudi1 <[email protected] notifications@github.com > kirjoitti 11.5.2019 kello 11.18:
No, I will give it a try …..
Von: Karan Harsh Wardhan [mailto:[email protected]]
Gesendet: Samstag, 11. Mai 2019 09:46
An: xamarin/xamarin-android <[email protected] xamarin-android@noreply.github.com >
Cc: TFreudi1 <[email protected] TFreudi1@gmx.de >; Mention <[email protected] mention@noreply.github.com >
Betreff: Re: [xamarin/xamarin-android] Archiving failed: An item with the same key has already been added (#3063)@TFreudi1 https://github.com/TFreudi1 are you running VS as administrator?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/xamarin/xamarin-android/issues/3063#issuecomment-491488918 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABEFA2IFU453GEGEYCHZMC3PUZ2S5ANCNFSM4HKRZ2AA . https://github.com/notifications/beacon/ABEFA2KMTVVGUAA43LEF2SDPUZ2S5A5CNFSM4HKRZ2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVFYNFQ.gif—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/xamarin/xamarin-android/issues/3063#issuecomment-491491187 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABEFA2IP5PQRBCVH72PYPWTPUZ7A7ANCNFSM4HKRZ2AA . https://github.com/notifications/beacon/ABEFA2PDI7A6B43ISZTGCALPUZ7A7A5CNFSM4HKRZ2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVFY64Y.gif
I found the solution !!
Tools > Options > Xamarin > Archives Location
If the path does not ends with a \ it fails to archive. Just add a \ at the end.A microsoft developer is not used to Path.Combine ?!!!
Solution 1:
for me the archives folder was not present so I manually created it
C:\Users\Lucy\AppData\Local\Xamarin\Mono for Android\Archive
Solution 2:
Another way it got worked was:
Update from the team on https://developercommunity.visualstudio.com/content/problem/556205/failed-to-create-app-archive-an-item-with-same-key.html:
Hi All,
Update on this issue. As mentioned last week, we got a potential fix. We want to share early bits from this link which can be installed on top of Visual Studio 16.1 Preview 3 (it can be downloaded from https://www.visualstudio.com/vs/preview).
The above bits are only intended for verification, that's why we strongly suggest to install it on top of a Preview instance of Visual Studio.
If you prefer to wait for the official bits, you can still try to use the potential workarounds mentioned in this thread (as Unloading the iOS projects from your solution before trying to create the Archive)
However, that workaround is reported as not working on some scenarios, and we would like to get user confirmation for the fix from the bits shared above particularly on those cases.
We're looking forward for your feedback on this fix.
Thank you!
Now that GitHub offers an option to customize notifications for Issues to notify specifically when Issues are closed or reopened, I'll also reopen this GitHub issue and re-close it once the corresponding Developer Community item status is updated to "Fix Released," in case anyone wants to use those issue notification options on this issue.
Yes the solution was to manually change the versionName in the android manifest
Getting this issue in VS preview 2019. Changing the version code did not work. Adding the back-slash to the path did.
Also having this issue.
Changing the path to include the backslash did not work, nor did deleting the bin and obj folders.
What did work for me was to edit the AndroidManifest.xml directly and change both the versionName and versionCode. I usually just change them in the properties dialog but that is not working at the moment.
Same for me, only changing manually Manifest is working, but beacause I don’t wanna change these I archive with vs2017 without any problems.
Von: SimonW [mailto:[email protected]]
Gesendet: Freitag, 17. Mai 2019 17:23
An: xamarin/xamarin-android xamarin-android@noreply.github.com
Cc: TFreudi1 TFreudi1@gmx.de; Mention mention@noreply.github.com
Betreff: Re: [xamarin/xamarin-android] Archiving failed: An item with the same key has already been added (#3063)
Also having this issue.
Changing the path to include the backslash did not work, nor did deleting the bin and obj folders.
What did work for me was to edit the AndroidManifest.xml directly and change both the versionName and versionCode. I usually just change them in the properties dialog but that is not working at the moment.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/xamarin/xamarin-android/issues/3063?email_source=notifications&email_token=ABEFA2KT34Z3YQALKLVQYTDPV3EWLA5CNFSM4HKRZ2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVVB4EI#issuecomment-493493777 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABEFA2M6RMPQBDIK22UCGI3PV3EWLANCNFSM4HKRZ2AA . https://github.com/notifications/beacon/ABEFA2IMNEKLFSUS6IK64J3PV3EWLA5CNFSM4HKRZ2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVVB4EI.gif
I found the solution !!
Tools > Options > Xamarin > Archives Location
If the path does not ends with a \ it fails to archive. Just add a \ at the end.A microsoft developer is not used to Path.Combine ?!!!
Thank you very much, this was driving me crazy.
Resolution to the above issue
Hi same error here. VS 2019 16.0.3.
Add \ to Archives Location not work for me.
I delete all content of Archive path, change Version Numbrer and Version Name. nothing work.
A fix for this issue should have been released as part of the VS 16.1 release. If this issue is still occurring after an upgrade, please report back!
On second thought, it looks like this issue may be referenced in, and tracking, multiple Developer Community issues. While the following issue has been marked as resolved:
There is still an open issue being tracked in:
I'll reopen this.
i had solve this problem. thank's nitinjs and Willempipi for solution
This is happening for me. Tried all suggestions, none of them solve the issue. I'm using VS Community 2019 16.0.4
Still facing this issue... What a nightmare... Why can't we still change the path of ios archive... Struggling with this issue since a while... Don't tell me it's hard to do... Just copy paste what you did for Android to iOS settings and you are done... :)
Both linked DevCom issues have been resolved, assuming this is fixed.
Most helpful comment
I found the solution !!
Tools > Options > Xamarin > Archives Location
If the path does not ends with a \ it fails to archive. Just add a \ at the end.
A microsoft developer is not used to Path.Combine ?!!!