Error while building Addressables

I’m getting the following errors while trying to build the addressables:

1:
An asset is marked with HideFlags.DontSave but is included in the build:
Asset: ‘Library/unity default resources’
Included from scene: ‘Assets/Scenes/MainMenuScene.unity’
Asset name: GUISkin
(You are probably referencing internal Unity data in your build.)
UnityEditor.GenericMenu:CatchMenu (object,string[ ],int)

2:
Build Task WriteSerializedFiles failed with exception:
Could not find file “C:\Users\anton\Documents\Repository\src\Library\BuildCache\09\09ce8b0817aa172c31c2406eb8cb0d48\8d13ef0b72bb794afb62efa3c0f57ec8\CAB-a454b013b8e1832c5df47a3870b9e2ef”
at System.IO.FileStream…ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileStream…ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileStream…ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.FileStream…ctor(string,System.IO.FileMode,System.IO.FileAccess)
at UnityEditor.Build.Pipeline.Utilities.HashingMethods.CalculateFile (System.String filePath) [0x00000] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Utilities\HashingMethods.cs:488
at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.CalculateFileMetadata (UnityEditor.Build.Content.WriteResult& result) [0x0002f] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Tasks\WriteSerializedFiles.cs:134
at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility.IRunCachedCallbacks<UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.Item>.ProcessUncached (UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility+WorkItem1[T] item) [0x000bb] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Tasks\WriteSerializedFiles.cs:178 at UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility.RunCachedOperation[T] (UnityEditor.Build.Pipeline.Interfaces.IBuildCache cache, UnityEditor.Build.Pipeline.Interfaces.IBuildLogger log, UnityEditor.Build.Pipeline.Interfaces.IProgressTracker tracker, System.Collections.Generic.List1[T] workItems, UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility+IRunCachedCallbacks1[T] cbs) [0x00177] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Utilities\TaskCachingUtility.cs:100 at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.Run () [0x0003b] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Tasks\WriteSerializedFiles.cs:120 at UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) [0x00099] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Shared\BuildTasksRunner.cs:56
UnityEditor.GenericMenu:CatchMenu (object,string[ ],int)

3:
SBP ErrorException
UnityEditor.GenericMenu:CatchMenu (object,string[ ],int)

4:
Addressable content build failure (duration : 0:01:37.412)
UnityEditor.GenericMenu:CatchMenu (object,string[ ],int)

Things i have tried so far:
1- Deleting the mentioned ‘Assets/Scenes/MainMenuScene.unity’ scene, doesn’t fix the issue as after trying to build the game without the scene the same error happens but referencing another scene.
2- Making sure none of my scripts has the “using UnityEditor;” directive (anywhere i use it in my script is also between “#if UNITY_EDITOR” and “#endif”.
3- Deleting the Library folder.
4- Reimporting the Assets folder.
5- Enabling/Disabling MonoScript Bundle Naming, as well as trying all the different options in that.
6- Enabling/Disabling Non-Recursive Dependency Calculation.
7- Also tried out all the options on the Shader Naming.

Also worth noticing:
1- Disabling MonoScript Bundle Naming makes it so no error is thrown during the addressables building process, however it makes any kind of addressable files completely broken inside game builds (works fine in editor play mode), the first scene works fine in standalone builds since it’s not an addressable, however any scene after that is broken and full of errors.
2- In the editor, changing Play Mode Scripts to advanced makes the game work fine, however using “Existing Build” (if MonoScript Bundle Naming is disabled - since while enabled it throws the above error) makes the game completely broken as well, only the starting scene works since it’s not an addressable.
3- I can’t reproduce the issue since it’s a very large project.
4- I can’t attach the project since it’s very large.
5- I have been using addressables for over an year and i have never experienced such problem, the problem didn’t appear after updating the Addressables package.
6- I was experiencing this issue in the 1.18.15 version, upgraded to 1.19.4 but that did not fix the problem.

Current Addressables package version: 1.19.4
Current Unity Version: 2020.3.18f1

Can’t edit the post due to some error so i’m making this reply.

Things i have tried so far:
8- Deleting the Graphics asset on the project folder.
Edit:
9- Removing all gameobjects from the “MainMenuScene” still throws the same error on that same scene, meaning the error happens on clean/empty scenes as well.

Worth mentioning:
7- I searched google and some people were having problems with the DoozyUI package which i do not use.

I’ll flag with the team!

1 Like

Hi @Houtamelo sounds like you’re running into the same issue as: Unity Issue Tracker - Addressables Build fails when GUISkin is part of the bundle and &#39;MonoScript Bundle Naming Prefix&#39; is not disabled

As a workaround, could you try downgrading to Addressables 1.17.17? That’s the version before the Monoscript bundle naming options were introduced (1.18.2).

1 Like

Tried downgrading, but the addressables are still broken inside game builds (i can build the addressables).
The only reason i enabled MonoScript Bundle Naming was to check if it would fix my problem, because addressables was building it was just not working inside standalone builds (and on the inspector with the PlayScript “Use Existing Build” option).

@Houtamelo Oh I see, so you’re able to build Addressables successfully (without errors) but loading data from AssetBundles still fails (running the game builds or when using the “Use Existing Build” playmode script in the Editor)?

If so, then the ticket mentioned only applies for the case where you’re seeing the GUI skin build errors. Could you elaborate more on the errors you’re seeing at runtime?

The other playmode scripts load Assets from the Project files, not from the AssetBundles created after building Addressables. So it is possible for the other playmode scripts to load Assets successfully while the “Use Existing Build” playmode script fails to load any Assets.

1 Like

Yes, i can successfuly build the addressables with no errors or warnings. (if monoscript is disabled)
I can load some of the Addressables in-game, however some of the loading operations result in null values, the ones that don’t give me broken assets, e.g. an addressable scene loaded comes with missing objects, the objects that are not missing have a bunch of null references (even simple ones like UI Images come with a different(usually null) sprite than it originally had). Many monobehaviours attached to gameobjects in such scenes come with null references (in both cases were they are referencing assets or objects in that scene).

In the end it results on standalone builds that don’t work past the first scene (the first scene is not an addressable).

Worth Mentioning:
Before making any standalone build i always make sure to build the addressable content, i even try purging the previous build cache before doing that.

Hmm have you tried deleting your catalog cache before building addressable content? It’s located in: Application.persistentDataPath\com.unity.addressables. It might still be pointing to the old cache prior to upgrading the Addressables package.

Otherwise could you share your editor log file? It should be located here: Unity - Manual: Log files

1 Like

I used “Debug.Log(Application.persistentDataPath);” to find the folder, went there and there was no “com.unity.addressables” folder or file, just “Player.log” and “Player-prev.log”.

Editor log is attached.

7503020–924536–Editor.txt (37.4 KB)

I see, since the folder doesn’t exist then no catalogs have been cached.

Sorry might not have been clear before, but could you share any log file (Player.log, or Editor.txt) that shows the errors being logged when running the player or using the “Use Existing Build” playmode script in the Editor?

1 Like

Here’s a log file for each situation.
It is worth mentioning that the errors shown here do not represent the actual broken state of the addressables files, quoting my first post:

7503166–924578–Editor.txt (178 KB)
7503166–924581–Player.txt (7.93 KB)

Thank you! I see that the NullReferenceException logs are not that helpful, it’s just saying that whatever the SortEntryButtons are referencing is null. Are they referencing an asset that’s Addressable? If so, are you using the AssetReference class to reference the asset?

1 Like

I don’t use the AssetReference class on my project, whenever i want to get an addressable i use it’s address.
The CodexPanel class that holds the SortEntryButtons() method is also an addressable which is loaded after all my static classes are initiliazed.
The NullReferenceException happens on this object:

[SerializeField] private List<CodexEntryButton> codexEntryButtons = new List<CodexEntryButton>();

This list is serialized by Unity and has by default around 30 CodexEntryButtons (which are MonoBehaviours).
To make sure the list is not null i also added this line at the start of the Awake method (SortEntryButtons() is called at the end of the Awake method).

 codexEntryButtons ??= new List<CodexEntryButton>();

That NullReferenceException is only one among many of problems while using “Existing Build”/Standalone Build.
Here’s some more screenshots of the issues, Text Mesh Pro Font Assets are not loading (i reference them inside an addressable scriptable object), the sprites are simply wrong on the scenes.

I included a comparison of the main menu on “Use Asset Database” vs “Use Existing Build”, as well as how the Pause Menu is on “Use Asset Database” (the PauseMenu on “Use Existing Build” is simply a white screen but i can still interact with the buttons (by pressing down Left Mouse on where the button should be).

7509452--925846--HowItIs.png
7509452--925847--HowItShouldBe.png
7509452--925850--PauseMenu.png

I see, are the CodexEntryButtons and Text Mesh Pro Font Assets addressable as well? You may be referencing Project files that don’t actually get included in the AssetBundles, and become null references in the “Existing Build” playmode/Standalone Build.

The CodexEntryButtons are prefabs and addressables, the TMP Font assets are not, just the scriptable object that references them.

Shouldn’t they be included in the build through the recursive dependency check? It always worked without needing to turn every single asset into an addressable. Previously (2 months ago) i only needed to turn the asset i want to load into an addressable and during the Content Build it would include any assets referenced by the addressable.

I didn’t change the CodexEntryButtons or the Font Assets recently, neither did i change how i load them and it previously worked fine.

Hmm I tested how your TMP Font assets set up (loading an addressable ScriptableObject that references TMP Font assets), and it does load correctly.

Are you be able to reproduce the issue on a new project? Maybe pick one of your existing scenes that when loaded, contains (1) a missing object and (2) an object with a null reference.

I was not able to reproduce it on a new project, copying and the scenes to the new project (and the assets the scenes need) did not present the issue.

Update, I tried the following, in this order:

1=> Uninstalling the Addressables Package
2=> Deleting the Addressable Assets Folder
3=> Closing the Unity Editor
4=> Opening the Unity Editor
5=> Reinstalling the Addressables Package
6=> Making every file that was previously addressable an addressable again and putting it in the same group as before
7=> Entering the editor play mode (using the fastest option) to make sure the game is still working and it was working fine
8=> Building the Addressables Content
9=> Entering the editor play mode (using the “Use existing Build” option), the game still has the exact same issues.
10=> Creating a standalone build and testing it, still has the exact same issues.

Update: Part of the issue is the same as this one: Incorrect display of sprites when using Addressables

The monoscript bundle option will be fixed with Scriptable Build Pipeline 1.19.3 release.
In the short term, if you want to modify your local copy of Scriptable Build Pipeline to fix this, here are the changes:

In CreateMonoScriptBundle.cs add to the using section:
using UnityEditor.Build.Utilities;
Then in the Run() update the type check from this:
if (usedTypes *!= monoScript)*
to this:
if (usedTypes _!= monoScript || usedSet*.filePath.Equals(CommonStrings.UnityDefaultResourcePath, StringComparison.OrdinalIgnoreCase))*
Attached is the updated code file._

7535876–930683–CreateMonoScriptBundle.cs (2.46 KB)

1 Like