android: Archiving failed: An item with the same key has already been added
Steps to Reproduce
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.
Expected Behavior
Archive correctly without having to change the versionName.
Actual Behavior
Fails. See logs.
Version Information
VS2019 16.1.0 Preview 2. Also happen with other VS versions.
Xamarin Tools Log File
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'.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 37 (5 by maintainers)
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 ?!!!
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!
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:notifications@github.com] 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
Update from the team on https://developercommunity.visualstudio.com/content/problem/556205/failed-to-create-app-archive-an-item-with-same-key.html:
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.
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?