Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

ArgumentException: An item with the same key has already been added.

Discussion in 'Addressables' started by MagicDesignEmerick, Feb 28, 2020.

  1. MagicDesignEmerick

    MagicDesignEmerick

    Joined:
    Oct 4, 2017
    Posts:
    26
    When opening unity, we sometimes have the following log :
    Code (CSharp):
    1. ArgumentException: An item with the same key has already been added. Key: Check Duplicate Bundle Dependencies
    2.       at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000c1] in <567df3e0919241ba98db88bec4c6696f>:0
    3.       at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
    4.       at UnityEditor.AddressableAssets.Build.AnalyzeRules.AnalyzeResultData.OnAfterDeserialize () [0x00005] in D:\jenkins\workspace\UHM\Library\PackageCache\com.unity.addressables@1.6.0\Editor\Build\AnalyzeRules\AnalyzeResultData.cs:31
    When this happens, we usually have errors in the final build regarding adressables, as they are not all built. The build otherwise is built correctly.

    Any idea what might cause that? We saw that just a couple days ago and it's hard to get what the cause might be as it's pretty random.

    We're on Unity 2019.2.13f1, using Addressables 1.6.2
     
    ahmet_unity573 likes this.
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Ancient thread, but I'm seeing the same error and there's not really any context to follow it. It occurs when doing a build from the Addressables Groups tab.

    Code (csharp):
    1. ArgumentException: An item with the same key has already been added. Key: 7cfa27aebb5612c4aa22dee300a322d5
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <fb001e01371b4adca20013e0ac763896>:0)
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <fb001e01371b4adca20013e0ac763896>:0)
    4. UnityEditor.Build.Pipeline.BundleBuildContent..ctor (System.Collections.Generic.IEnumerable`1[T] bundleBuilds) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.7.3/Editor/Shared/BuildContent.cs:161)
    5. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode.DoBuild[TResult] (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput builderInput, UnityEditor.AddressableAssets.Build.DataBuilders.AddressableAssetsBuildContext aaContext) (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:157)
    6. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode.BuildDataImplementation[TResult] (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput builderInput) (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:78)
    7. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase.BuildData[TResult] (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput builderInput) (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/Build/DataBuilders/BuildScriptBase.cs:74)
    8. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContentImpl () (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/Settings/AddressableAssetSettings.cs:1722)
    9. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent () (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/Settings/AddressableAssetSettings.cs:1704)
    10. UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor.OnBuildPlayerData () (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/GUI/AddressableAssetsSettingsGroupEditor.cs:270)
    11. UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor.OnBuildScript (System.Object context) (at Library/PackageCache/com.unity.addressables@1.8.5/Editor/GUI/AddressableAssetsSettingsGroupEditor.cs:265)
    12. UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at <d7545a46516941d4b2f2dec578cd41ee>:0)
    I would assume it's trying to tell me that maybe an asset exists in multiple bundles, but why not throw a warning up or something instead? It just falls on its face here.
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,795
    I'll ping the team. Which version of Addressables are you using?
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    1.8.5 on Unity 2019.4.8f1. The error was persisting through restarts etc. Recreating the addressable groups did not resolve.

    I deleted all of the bundles and addressable groups, then recreated them and it seemed to resolve. I can't repro the error anymore.
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,795
    That's a pretty old version of the package. Could you try updating and see if that helps?
     
  6. rickypu

    rickypu

    Joined:
    Aug 7, 2013
    Posts:
    9
    how to find the key resource?
    Code (CSharp):
    1. ArgumentException: An item with the same key has already been added. Key: ad7e587a1f3609b45bbc49c7b24db172
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <fb001e01371b4adca20013e0ac763896>:0)
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <fb001e01371b4adca20013e0ac763896>:0)
    4. UnityEditor.Build.Pipeline.BundleBuildContent..ctor (System.Collections.Generic.IEnumerable`1[T] bundleBuilds) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.17.0/Editor/Shared/BuildContent.cs:161)
    5. UnityEditor.AddressableAssets.Build.AnalyzeRules.BundleRuleBase.RefreshBuild (UnityEditor.AddressableAssets.Build.DataBuilders.AddressableAssetsBuildContext buildContext) (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/Build/AnalyzeRules/BundleRuleBase.cs:106)
    6. UnityEditor.AddressableAssets.Build.AnalyzeRules.BundleRuleBase.CalculateBuiltInResourceDependenciesToBundleDependecies (UnityEditor.AddressableAssets.Settings.AddressableAssetSettings settings, System.String[] builtInResourcesPaths) (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/Build/AnalyzeRules/BundleRuleBase.cs:281)
    7. UnityEditor.AddressableAssets.Build.AnalyzeRules.CheckResourcesDupeDependencies.RefreshAnalysis (UnityEditor.AddressableAssets.Settings.AddressableAssetSettings settings) (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/Build/AnalyzeRules/CheckResourcesDupeDependencies.cs:32)
    8. UnityEditor.AddressableAssets.Build.AnalyzeSystem.RefreshAnalysis (UnityEditor.AddressableAssets.Build.AnalyzeRules.AnalyzeRule rule) (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/Build/AnalyzeRules/AnalyzeSystem.cs:164)
    9. UnityEditor.AddressableAssets.GUI.AssetSettingsAnalyzeTreeView.<RunAllSelectedRules>b__4_0 (UnityEditor.AddressableAssets.GUI.AnalyzeRuleContainerTreeViewItem ruleContainer) (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/GUI/AssetSettingsAnalyzeTreeView.cs:69)
    10. UnityEditor.AddressableAssets.GUI.AssetSettingsAnalyzeTreeView.PerformActionForEntireRuleSelection (System.Action`1[T] action) (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/GUI/AssetSettingsAnalyzeTreeView.cs:60)
    11. UnityEditor.AddressableAssets.GUI.AssetSettingsAnalyzeTreeView.RunAllSelectedRules () (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/GUI/AssetSettingsAnalyzeTreeView.cs:67)
    12. UnityEditor.AddressableAssets.GUI.AnalyzeRuleGUI.<OnGUI>b__3_0 () (at Library/PackageCache/com.unity.addressables@1.17.15/Editor/GUI/AnalyzeRuleGUI.cs:38)
    13. UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at <42d975c3c02743a7bdf5c81753993fc0>:0)
     
  7. ickydime

    ickydime

    Joined:
    Nov 20, 2012
    Posts:
    110
    Same issue. Unity 2019.4.18f and Addressables 1.16.19

    I just was on 1.16.10 when I first got the error.

    I had opened a project I hadn't touched in a month. Added 4 new prefabs to an addressable group. Assigned their label and shorted their addressable name. Then clicked build and got this error.

    Tried cleaning and rebuilding but it persisted.

    I assumed it was something with the 4 new prefabs so I removed them and clicked build and I continue to get the error.

    Looks like the last person to mess with the addressables was a teammate. Perhaps there is a clash in their setup versus mine?

    I ended up closing unity. Cleaning the cache again. Then rebuilding. Now it works.
     
    chrismarch likes this.
  8. Dr-Nick

    Dr-Nick

    Joined:
    Sep 9, 2013
    Posts:
    25
    I had the issue recently. I was on addressables 1.10.0 and updated to a later version 1.18.9 and the update alone didn't fix it.

    I decided to look at AddressableGroups window and remove the recently added entries and found that some how each entry was added twice.

    ie. I deleted an entry but the entry remained in the group list. It was only after I tried deleting the entry again that it disappeared.

    So somehow I did indeed add an Addressable entry twice but the window excludes showing any duplicates.
     
    slice3d likes this.
  9. mikematthews

    mikematthews

    Joined:
    Oct 8, 2016
    Posts:
    1
    Had this issue myself on Addressables 1.18.16 this week. Seems to be the same as Dr-Nick had above. After removing all of the recently added Addressable entries and then adding them again, the error went away, but there were no duplicates listed in the Addressables Groups window, and the console didn't give any specifics. It would be really great if there was a way to know which Addressables were being duplicated.
     
  10. alejandro_palmero_wwtk

    alejandro_palmero_wwtk

    Joined:
    Jul 28, 2021
    Posts:
    3
    the duplicate key is a GUID and you can search in the whole project folder to find references
     
    chrismarch likes this.
  11. gabsxrubin

    gabsxrubin

    Joined:
    May 9, 2021
    Posts:
    1
    I get a similar issue although it doesn't have anything to do with Addressable Assets. The error does say I'm missing a key.

    The error I get. I'm not really sure what's going on so any help would be appreciated!

    /Applications/Unity/Hub/Editor/2021.2.2f1/Unity.app/Contents/il2cpp/build/deploy/il2cpp @Library/Bee/artifacts/rsp/6827040134566167516.rsp
    Error: IL2CPP error (no further information about what managed code was being converted is available)
    System.ArgumentException: An item with the same key has already been added. Key: mscorlib
    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    at Unity.IL2CPP.DataModel.BuildLogic.CecilLoading.AssemblyCache.Populate(IEnumerable`1 assemblies) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic.CecilLoading/AssemblyCache.cs:line 33
    at Unity.IL2CPP.DataModel.BuildLogic.CecilLoading.CecilAssemblyLoader.LoadDeferred(ReadOnlyCollection`1 allAssemblyPaths, LoadParameters parameters) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic.CecilLoading/CecilAssemblyLoader.cs:line 69
    at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.Initialize(UnderConstruction`2& systemAssembly) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/DataModelBuilder.cs:line 263
    at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.Build() in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/DataModelBuilder.cs:line 49
    at Unity.IL2CPP.AssemblyConversion.Phases.InitializePhase.Run(AssemblyConversionContext context) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP/AssemblyConversion/Phases/InitializePhase.cs:line 19
    at Unity.IL2CPP.AssemblyConversion.Classic.ClassicConverter.Run(AssemblyConversionContext context) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP/AssemblyConversion.Classic/ClassicConverter.cs:line 11
    at Unity.IL2CPP.AssemblyConversion.AssemblyConverter.ConvertAssemblies(AssemblyConversionInputData data, AssemblyConversionParameters parameters, AssemblyConversionInputDataForTopLevelAccess dataForTopLevel) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP/AssemblyConversion/AssemblyConverter.cs:line 30
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun () (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindow.cs:179)
     
  12. fish-rp

    fish-rp

    Joined:
    May 6, 2021
    Posts:
    9
    Experiencing a similar error as above in Unity 2020.3 when generating a Linux x86_64 IL2CPP build

    Code (CSharp):
    1. Fatal error in Unity CIL Linker
    2. System.ArgumentException: An item with the same key has already been added. Key: mscorlib
    3.    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    4.    at Unity.Linker.EngineStripping.EngineModuleResolver.Initialize(UnityLinkContext context, AssemblyDefinition unityEngineFacade, ModulesAssetFile modulesAssetFile)
    5.    at Unity.Linker.EngineStripping.EngineStrippingContext.Initialize(AssemblyDefinition unityEngineFacade)
    6.    at Unity.Linker.Steps.InitializeEngineStrippingStep.Process()
    7.    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
    8.    at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
    9.    at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
    10.    at Mono.Linker.Pipeline.Process(LinkContext context)
    11.    at Unity.Linker.UnityDriver.UnityRun(ILogger customLogger)
    12.    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(ILogger customLogger)
    13.    at Unity.Linker.UnityDriver.RunDriver()
    14. stderr:
     
  13. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
    Simalar issue too. When Trying to build for WebGl, with wn empty project of Unity Editor 2021.3.1:
    keep having 'An item with the same key has already been added. Key: mscorlib'

    Building Library\Bee\artifacts\WebGL\ManagedStripped failed with output:
    C:\Program Files\Unity\Hub\Editor\2021.3.1f1\Editor\Data\il2cpp\build\deploy\UnityLinker.exe --search-directory=C:/_ToBurn/_ProjMy/Unity/NGToolEMptyProject_Test/Temp/StagingArea/Data/Managed --out=Library/Bee/artifacts/WebGL/ManagedStripped --include-link-xml=C:/_ToBurn/_ProjMy/Unity/NGToolEMptyProject_Test/Temp/StagingArea/Data/Managed\TypesInScenes.xml --include-directory=C:/_ToBurn/_ProjMy/Unity/NGToolEMptyProject_Test/Temp/StagingArea/Data/Managed --dotnetprofile=unityaot-linux --dotnetruntime=Il2Cpp --architecture=EmscriptenJavaScript --platform=WebGL --use-editor-options --enable-engine-module-stripping --engine-modules-asset-file=C:/Program Files/Unity/Hub/Editor/2021.3.1f1/Editor/Data/PlaybackEngines/WebGLSupport/modules.asset --editor-data-file=C:/_ToBurn/_ProjMy/Unity/NGToolEMptyProject_Test/Temp/StagingArea/Data/Managed/EditorToUnityLinkerData.json --print-command-line
    Fatal error in Unity CIL Linker
    System.ArgumentException: An item with the same key has already been added. Key: mscorlib
    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    at Unity.Linker.EngineStripping.EngineModuleResolver.Initialize(UnityLinkContext context, AssemblyDefinition unityEngineFacade, ModulesAssetFile modulesAssetFile)
    at Unity.Linker.EngineStripping.EngineStrippingContext.Initialize(AssemblyDefinition unityEngineFacade)
    at Unity.Linker.Steps.InitializeEngineStrippingStep.Process()
    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
    at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
    at Mono.Linker.Pipeline.Process(LinkContext context)
    at Unity.Linker.UnityDriver.UnityRun(Boolean noProfilerAllowed, ILogger customLogger)
    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(ILogger customLogger, Boolean noProfilerAllowed)
    at Unity.Linker.UnityDriver.RunDriver()
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I'm not quite sure what the cause of this issue is. You might be able to work around it by disabling the "Strip Engine Code" option in the Player Settings though. I'm curious to see if that will allow it to build, or if it will lead to a different error message later.
     
  15. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
    Hi, thank you for reply. So I test with your suggestion but it doesn't works (unity 2021.3.2:
    upload_2022-5-11_8-24-15.png

    Code (CSharp):
    1. Building Library\Bee\artifacts\WebGL\ManagedStripped failed with output:
    2. C:\Program Files\Unity\Hub\Editor\2021.3.2f1\Editor\Data\il2cpp\build\deploy\UnityLinker.exe --search-directory=C:/_ToBurn/_ProjMy/Unity/3DNotes_ReduxAsmDef/Temp/StagingArea/Data/Managed --out=Library/Bee/artifacts/WebGL/ManagedStripped --include-link-xml=C:/_ToBurn/_ProjMy/Unity/3DNotes_ReduxAsmDef/Temp/StagingArea/Data/Managed\TypesInScenes.xml --include-directory=C:/_ToBurn/_ProjMy/Unity/3DNotes_ReduxAsmDef/Temp/StagingArea/Data/Managed --dotnetprofile=unityaot-linux --dotnetruntime=Il2Cpp --architecture=EmscriptenJavaScript --platform=WebGL --use-editor-options --engine-modules-asset-file=C:/Program Files/Unity/Hub/Editor/2021.3.2f1/Editor/Data/PlaybackEngines/WebGLSupport/modules.asset --editor-data-file=C:/_ToBurn/_ProjMy/Unity/3DNotes_ReduxAsmDef/Temp/StagingArea/Data/Managed/EditorToUnityLinkerData.json --print-command-line
    3. Fatal error in Unity CIL Linker
    4. System.ArgumentException: An item with the same key has already been added. Key: mscorlib
    5.    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    6.    at Unity.Linker.EngineStripping.EngineModuleResolver.Initialize(UnityLinkContext context, AssemblyDefinition unityEngineFacade, ModulesAssetFile modulesAssetFile)
    7.    at Unity.Linker.EngineStripping.EngineStrippingContext.Initialize(AssemblyDefinition unityEngineFacade)
    8.    at Unity.Linker.Steps.InitializeEngineStrippingStep.Process()
    9.    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
    10.    at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
    11.    at Mono.Linker.Pipeline.Process(LinkContext context)
    12.    at Unity.Linker.UnityDriver.UnityRun(Boolean noProfilerAllowed, ILogger customLogger)
    13.    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(ILogger customLogger, Boolean noProfilerAllowed)
    14.    at Unity.Linker.UnityDriver.RunDriver()
    15. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    16.  
    17. BuildFailedException: Incremental Player build failed!
    18. UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <a017e354f3154926a5617fbac3a64fcc>:0)
    19. UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:158)
    20. UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <a017e354f3154926a5617fbac3a64fcc>:0)
    21. UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <a017e354f3154926a5617fbac3a64fcc>:0)
    22. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    23.  
    24. Build completed with a result of 'Failed' in 4 seconds (3808 ms)
    25. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    26.  
    27. UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
    28.   at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <a017e354f3154926a5617fbac3a64fcc>:0
    29.   at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <a017e354f3154926a5617fbac3a64fcc>:0
    30. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    31.  
    32.  
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Odd - I'm surprised that code is running when engine code stripping is disabled. Can you submit a bug report for this issue?
     
  17. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
    It works now. Ok here is what i do ( it's extreme, but i have tried many things and none fixed it):

    - Uninstall All unity Editor
    - Then Uninstall UnityHub
    - Reinstall UnitHub
    - Reinstall Unity editor 2021.3.2
    - create new empty poject, build webgl:
    --> it works
     
  18. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
    !? But, I then open a project that had issue building webGl, It still not works.

    And now event the empty project that was working, it's no more working!?

    Event with a new empty project.

    It through this similar/same error:

    Code (CSharp):
    1. Building Library\Bee\artifacts\WebGL\ManagedStripped failed with output:
    2. C:\Program Files\Unity\Hub\Editor\2021.3.2f1\Editor\Data\il2cpp\build\deploy\UnityLinker.exe --search-directory=C:/_ToBurn/_ProjMy/Unity/My project (3)/Temp/StagingArea/Data/Managed --out=Library/Bee/artifacts/WebGL/ManagedStripped --include-link-xml=C:/_ToBurn/_ProjMy/Unity/My project (3)/Temp/StagingArea/Data/Managed\TypesInScenes.xml --include-directory=C:/_ToBurn/_ProjMy/Unity/My project (3)/Temp/StagingArea/Data/Managed --dotnetprofile=unityaot-linux --dotnetruntime=Il2Cpp --architecture=EmscriptenJavaScript --platform=WebGL --use-editor-options --enable-engine-module-stripping --engine-modules-asset-file=C:/Program Files/Unity/Hub/Editor/2021.3.2f1/Editor/Data/PlaybackEngines/WebGLSupport/modules.asset --editor-data-file=C:/_ToBurn/_ProjMy/Unity/My project (3)/Temp/StagingArea/Data/Managed/EditorToUnityLinkerData.json --include-unity-root-assembly=C:/_ToBurn/_ProjMy/Unity/My project (3)/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll --print-command-line
    3. Fatal error in Unity CIL Linker
    4. System.ArgumentException: An item with the same key has already been added. Key: mscorlib
    5.    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    6.    at Unity.Linker.EngineStripping.EngineModuleResolver.Initialize(UnityLinkContext context, AssemblyDefinition unityEngineFacade, ModulesAssetFile modulesAssetFile)
    7.    at Unity.Linker.EngineStripping.EngineStrippingContext.Initialize(AssemblyDefinition unityEngineFacade)
    8.    at Unity.Linker.Steps.InitializeEngineStrippingStep.Process()
    9.    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
    10.    at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
    11.    at Mono.Linker.Pipeline.Process(LinkContext context)
    12.    at Unity.Linker.UnityDriver.UnityRun(Boolean noProfilerAllowed, ILogger customLogger)
    13.    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(ILogger customLogger, Boolean noProfilerAllowed)
    14.    at Unity.Linker.UnityDriver.RunDriver()
    15. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    16.  
    17. BuildFailedException: Incremental Player build failed!
    18. UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <a017e354f3154926a5617fbac3a64fcc>:0)
    19. UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:158)
    20. UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <a017e354f3154926a5617fbac3a64fcc>:0)
    21. UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <a017e354f3154926a5617fbac3a64fcc>:0)
    22. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    23.  
    24. Build completed with a result of 'Failed' in 15 seconds (15284 ms)
    25. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    26.  
    27. UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
    28.   at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <a017e354f3154926a5617fbac3a64fcc>:0
    29.   at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <a017e354f3154926a5617fbac3a64fcc>:0
    30. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    31.  
    32.  
     
    Last edited: May 11, 2022
  19. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
    By reinstalling Unity (2021.3.2) (No need to reinstall Unity Hub tho), it works for new empty project. But, i wont try again, to open a project that didn't work, bcz it gonna make any project won't works any more. For Build WebGl

    Weird!
     
  20. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
  21. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    I updated a project from Unity 2018, to 2020 and this error keeps spamming the console while the scene is open in the editor. Really at a loss to know what's causing it, as clicking on the error message doesn't tell me anything or link to anything in the hierarchy...

    So, after disabling everything in the scene (hundreds of objects) and then going through one by one, I found the Post Process Layer on the main camera to be triggering this error.
     
    Last edited: Jun 10, 2022
    Brightori likes this.
  22. Moritz5thPlanet

    Moritz5thPlanet

    Joined:
    Feb 5, 2019
    Posts:
    73
    Issue still persists, was able to have it randomly go away, but no idea what caused it.

    Previously, I always had to clear the Addressables build cache.

    This is on Unity 2022.2.8f1, Target Android, Addressables 1.21.2

    Code (CSharp):
    1. Build Task CalculateSceneDependencyData failed with exception:
    2. An item with the same key has already been added. Key: 2ee06dfda3c38e7449cbdf7fe1f6610a
    3.   at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000dd] in <83161767e3f34f4a9c1453ea3e22d1f1>:0
    4.   at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <83161767e3f34f4a9c1453ea3e22d1f1>:0
    5.   at UnityEditor.Build.Pipeline.Tasks.CalculateSceneDependencyData.Run () [0x005f7] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.1\Editor\Tasks\CalculateSceneDependencyData.cs:225
    6.   at UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList`1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) [0x000cd] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.1\Editor\Shared\BuildTasksRunner.cs:56
    7. UnityEditor.GenericMenu:CatchMenu (object,string[],int)
    8.  
     
    Last edited: Apr 23, 2023
  23. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    145
    Yeah, just ran into this one as well.

    Had no issues, then all of the sudden Addressables broke my build with no way to recover.
    I looked up the asset guid and it appeared to be one of my scenes? I hadn't updated that scene recently, either.

    Unity 2022.2.18f
    Addressables 1.21.9
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
  25. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    145
    Personally, the reason I've never submitted a bug report is that it requires a lot of trust or a lot of effort. I'm not trusting enough to bundle up my game project folder to send for a bug report, and I generally don't have the time to repro in a clean project. That said, this is also one of those bugs where it's hard to repro until it becomes impossible not to repro.

    If there's a specific log or something that would help, I know I'd be more than happy to send that.

    To get around the issue, I've downgraded my project back to previous working versions

    editor 2021.3.24f
    addressables 1.21.8
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I completely get it.

    Yes, I think you can gather more data to help with this issue, if possible.

    You will need to use the "Diagnostics" settings in the Unity Editor to enable some special command line arguments for the UnityLinker tool (https://docs.unity3d.com/Manual/Preferences.html#diagnostics)

    Specifically, you will want to pass the "--enable-report" and "--enable-snapshot" arguments to the UnityLinker. You can find some discussion of this on the forums here: https://forum.unity.com/threads/ext...work-with-il2cpp-backend.728654/#post-8850241

    After the problem occurs, there should be a directory that you can zip up and send to me via DM. From there I can see if we have enough information to track down the cause of this issue.
     
  27. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    I can tell you what that one is, it’s this:
    https://forum.unity.com/threads/scriptable-build-pipeline-1-21-3-bug.1430047/
    There’s a fix on that thread.
     
  28. Suzuki_YE

    Suzuki_YE

    Joined:
    Aug 18, 2023
    Posts:
    2
    I have encountered similar issue (ArgumentException: An item with the same key has already been added) written in this thread with Addressables.Release() API in Unity 2022.3.7f1 & Addressables 1.21.15.

    I have reported this issue to bug report as CASE IN-51755 with attached reproduced project.

    Though I'm not sure if this issue is same as other issues in this thread, could you please check it in Unity team?

    Following is the copy of the bug report.
    --------------------------------------------------------------------------------
    1. What happened

    Addressables.Release() throws ArgumentException from the 2nd time


    2. How can we reproduce it using the example you attached

    [Instructions with attached project]
    1. Play (Ctrl-P)
    2. Stop (Ctrl-P) => Not reproduce
    3. Play (Ctrl-P)
    4. Stop (Ctrl-P) => Reproduce (ArgumentException appears on Console log)
    5. Play (Ctrl-P)
    6. Stop (Ctrl-P) => Reproduce (ArgumentException appears on Console log)
    7. ...

    [Detail Conditions]
    - Reproduced on Unity 2022.3.7f1 with Addressables 1.21.15. (Other conditions are not checked)
    - This issue only reproduces when Enter Play Mode Options = On and Reload Domain = Off.
    - This issue only reproduces when Play Mode Script = Use Existing Build. (Not reproduced with "Use Asset Database" or "Simulate Groups".)
    - This issue reproduces when Addressables.Release() is called on OnDestroy() or OnApplicationQuit(). But not reproduces in other MonoBehaviour event (such as Start(), Update(), etc.)
    - After occurs domain reload, this issue temporarily fixes, but occurs again from the 2nd time.
     
  29. Suzuki_YE

    Suzuki_YE

    Joined:
    Aug 18, 2023
    Posts:
    2
    Thanks to Unity team, this issue has been fixed in Addressables 1.21.17 as written in following bug tracker URL.

    https://issuetracker.unity3d.com/is...xception-when-play-mode-has-been-exited-twice

    The issue has been resolved perfectly on my environment.
    So, if you encountered similar issue written in this thread, the issue may be resolved with Addressables 1.21.17 or later.