Building addressables failed with InvalidCastException

Hi,

I’m trying to make a build on Android.
It failed, but logs suggested to build addressables first.
I’ve found the solution here .

So I clicked on Window -> Asset Management -> Addressables -> Groups -> Build -> New Default build, but it failed with the following error:

VSCode pointed to this line:

                foreach (var r in results.WriteResults)
                {
                    var resultValue = r.Value;
                    m_Linker.AddTypes(resultValue.includedTypes);
#if UNITY_2021_1_OR_NEWER
                    // Uncomment once PR 113067 lands in trunk.
                    //m_Linker.AddSerializedClass(resultValue.includedSerializeReferenceFQN);
#else
                    if (resultValue.GetType().GetProperty("includedSerializeReferenceFQN") != null)
/* >>> EXCEPTION >>> */    m_Linker.AddSerializedClass((string[])resultValue.GetType().GetProperty("includedSerializeReferenceFQN").GetValue(resultValue));
#endif
                }

Is it a bug in localization package or perhaps a problem with my configuration ?

I have never seen that error before. Have you tried updating to the latest version of Addressables?

1 Like

Oh…

I really thought I have everything up to date,
but it turned out that package manager doesn’t notify about possible packages dependencies updates.

I’ve updated Addressables from 1.16.6 to 1.16.15 and it worked.

Thanks.

2 Likes

Hi, same error, same issue, localization 0.9.0 target 1.16.6, so the package manager said I was up to date, but it was not the case.

Did updating fix it for you?

Update to 1.16.15 fixed the issue yes

2 Likes

I had the exact same issue. Addressables version 1.16.6 was used, but Unity wouldn’t tell me, that there is a newer version.
I guess, this happens, because addressables is only a transitive dependency (of localization in my case). Adding addressables explicitly solved the issue for me.

1 Like

Yeah, it uses the version the Localization package specifies at its minimum dependency. We have increased this version so that it will automatically update in 0.10.0 but its always a good idea to manually update it yourself if you encounter any issues.