Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Building addressables failed with InvalidCastException

Discussion in 'Localization Tools' started by marekzd, Dec 7, 2020.

  1. marekzd

    marekzd

    Joined:
    Jul 1, 2016
    Posts:
    33
    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:

    Code (CSharp):
    1.  
    2.                 foreach (var r in results.WriteResults)
    3.                 {
    4.                     var resultValue = r.Value;
    5.                     m_Linker.AddTypes(resultValue.includedTypes);
    6. #if UNITY_2021_1_OR_NEWER
    7.                     // Uncomment once PR 113067 lands in trunk.
    8.                     //m_Linker.AddSerializedClass(resultValue.includedSerializeReferenceFQN);
    9. #else
    10.                     if (resultValue.GetType().GetProperty("includedSerializeReferenceFQN") != null)
    11. /* >>> EXCEPTION >>> */    m_Linker.AddSerializedClass((string[])resultValue.GetType().GetProperty("includedSerializeReferenceFQN").GetValue(resultValue));
    12. #endif
    13.                 }
    14.  
    Is it a bug in localization package or perhaps a problem with my configuration ?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,227
    I have never seen that error before. Have you tried updating to the latest version of Addressables?
     
    Erethan likes this.
  3. marekzd

    marekzd

    Joined:
    Jul 1, 2016
    Posts:
    33
    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.
     
    Goty-Metal and karl_jones like this.
  4. paradizIsCool

    paradizIsCool

    Joined:
    Jul 10, 2014
    Posts:
    178
    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.
     

    Attached Files:

  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,227
    Did updating fix it for you?
     
  6. paradizIsCool

    paradizIsCool

    Joined:
    Jul 10, 2014
    Posts:
    178
    Update to 1.16.15 fixed the issue yes
     
    Erethan and karl_jones like this.
  7. magnetic_scho

    magnetic_scho

    Joined:
    Feb 2, 2020
    Posts:
    92
    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.
     
    Goty-Metal likes this.
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,227
    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.