Search Unity

  1. The 2021.2 beta is now available. To find out what's new, have a look at our 2021.2 beta blog post.
    Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  3. Dismiss Notice

Resolved Building addressables failed with InvalidCastException

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

  1. marekzd

    marekzd

    Joined:
    Jul 1, 2016
    Posts:
    28
    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:
    5,051
    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:
    28
    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:
    167
    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:
    5,051
    Did updating fix it for you?
     
  6. paradizIsCool

    paradizIsCool

    Joined:
    Jul 10, 2014
    Posts:
    167
    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:
    6
    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:
    5,051
    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.
     
unityunity