Search Unity

LocalizationSettings cannot be loaded when deployed on Android device.

Discussion in 'Localization Tools' started by zgrkpnr89, Jun 13, 2020.

  1. zgrkpnr89

    zgrkpnr89

    Joined:
    May 5, 2019
    Posts:
    6
    When I run the game on Editor everything works just fine. However, when I deploy the game on an Android device I get the following error message.

    A scripted object (probably UnityEngine.Localization.Settings.LocalizationSettings?) has a different serialization layout when loading
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Hi,
    This is a known issue. We are still looking into it. One thing we noticed is that code stripping of medium to high was causing a lot of issues? Are you using code stripping?
     
  3. zgrkpnr89

    zgrkpnr89

    Joined:
    May 5, 2019
    Posts:
    6
    Yes I am using the option High. After you reply I tried with low code stripping. This time I received the following error message when application is starting.

    MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[[System.Collections.Generic.IList`1[[UnityEngine.Localization.Locale, Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

    And when I tried to change language and use LocalizationSettings.AvailableLocales.Locales I received the following error message.

    Locales PreloadOperation has not been initialized, can not return the available locales.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    If you completely disable code stripping does it work?
     
  5. zgrkpnr89

    zgrkpnr89

    Joined:
    May 5, 2019
    Posts:
    6
    I disabled code stripping and got the following message.

    NullReferenceException: Object reference not set to an instance of an object
    at UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation.Execute () [0x00010] in <b97fd012af1e4f74947dbe23c89ff3ff>:0
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () [0x00000] in <96b8820f0254483eb9e6179681bc1182>:0
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) [0x00068] in <96b8820f0254483eb9e6179681bc1182>:0
    at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00000] in <96b8820f0254483eb9e6179681bc1182>:0
    at UnityEngine.AddressableAssets.Initialization.
    Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Collections.Generic.IList`1[UnityEngine.Localization.Locale]], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Locale, Type=UnityEngine.Localization.Locale

    Error message doesn't look very pretty but I couldn't format it well=)
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Did you build the addressable assets?
     
  7. zgrkpnr89

    zgrkpnr89

    Joined:
    May 5, 2019
    Posts:
    6
    Sorry for late response. I did not build addressables. I will build and try it. I will update my response as soon as I try.
     
    karl_jones likes this.
  8. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Is this fixed? @karl_jones

    I tried with disabling the managed stripping level. still i get the same error.

    Locales PreloadOperation has not been initialized, can not return the available locales.
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    That sounds like a different issue if it's happening with stripping disabled.
    Try updating to the latest Addressables version.
     
  10. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Locales PreloadOperation has not been initialized, can not return the available locales.

    I have got the latest Addressables and localization, all Localization files and settings are made addressables.

    Still i have this error.
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Can you share the log file?
     
  12. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Error log on Start of play mode in editor :
    Error Log :
    Code (CSharp):
    1.    IEnumerator Start()
    2.     {
    3.         locales = new List<Locale>();
    4.  
    5.         yield return LocalizationSettings.InitializationOperation;
    6.  
    7.         if (LocalizationSettings.InitializationOperation.IsDone)
    8.         {
    9.             int selected = 0;
    10.             for (int i = 0; i < LocalizationSettings.AvailableLocales.Locales.Count; ++i)
    11.             {
    12.                 var locale = LocalizationSettings.AvailableLocales.Locales[i];
    13.                 if (LocalizationSettings.SelectedLocale == locale)
    14.                     selected = i;
    15.                 locales.Add(locale);
    16.                 print("L :" + locale.name);
    17.             }
    18.             prevSelected = LocalizationSettings.SelectedLocale;
    19.         }
    20.     }
     
  13. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
  14. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Yes i did build the addressables. Please find the attached editor Log.
     

    Attached Files:

  15. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Looks like an issue with our GameViewLanguageMenu. Could you please file a bug report?
     
  16. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Sure will do that, you have any idea if i use the latest Unity version it will work fine?
     
  17. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    No it looks like a bug in the package.
     
    MoonbladeStudios likes this.
  18. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    I'm wondering if this issue has been resolved in the latest Localization package 0.11.1? I'm on 0.10.0.
     
  19. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Yes that was fixed some time ago although it's not really a localization bug. Updating to the latest unity should also fix it.
     
    cassius likes this.
  20. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    Same Issue "Version 1.0.0-pre.9 - May 12, 2021" Continues.
    "if (PlayerPrefs.HasKey("lang"))
    {
    LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(PlayerPrefs.GetString("lang"));
    }"
    Error Code I Get From Here
     
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    What error are you getting? We already have a PlayerPref LocaleSelector, just press the + button in the LocalizationSettings Locale Selectors menu.
     
  22. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    Localization Settings Locale Selectors Fixed When Installing Two Locale Thanks
     
    karl_jones likes this.
  23. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    Version 1.0.0-pre.10 Update Later
    Error : OperationException : SelectedLocale is null
     
  24. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    What do you mean?
    When do you get this, what platform? Can you share the log file?
     
  25. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    sure i will share
     

    Attached Files:

  26. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
  27. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    It happened after updating.
    There is none of the things in the 5th item, it seems that there is no problem.
    now it doesn't give that error.
     
  28. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    So its working now?
    Did you build the addressable assets?
     
  29. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    I'm getting the same errors I couldn't fix the addressing error I got a build I uninstalled it again the same I reinstalled Guinea the same problem
     
  30. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Im not sure I follow, Could you file a bug report?
     
  31. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    I am getting an error like

    OperationException : SelectedLocale is null

    UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1/<>c__DisplayClass57_0<UnityEngine.Localization.Settings.LocalizationSettings>:<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Settings.LocalizationSettings>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Settings.LocalizationSettings>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Settings.LocalizationSettings>) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Localization.InitializationOperation:<LoadLocales>b__10_0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Locale>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Locale>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Locale>) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1<UnityEngine.Localization.Locale>:OnWrappedCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Locale>)
    DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Locale>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.Localization.Locale>) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:69)
    UnityEngine.Localization.Components.LocalizeStringEvent:OnEnable () (at Library/PackageCache/com.unity.localization@1.0.0-pre.10/Runtime/Component Localizers/LocalizeStringEvent.cs:81)


    I'm Getting This Error in Unity Play. I Buided Android. Android Logcat. It's Working Correctly.
    One of the things I did when I got this error is I Reset All Scripts in Asset/AddressableAssetsDate

    I've Released the Buid Update, I'll Notify You If Firebase Freezes From There
     
    karl_jones likes this.
  32. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Can you file a bug report with the play mode error so we can look into it?
     
  33. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    Sorry I Don't Understand How To Do That Operation
     
  34. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
  35. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    ok I sent the problem with the first item
     
    karl_jones likes this.
  36. marioshrist

    marioshrist

    Joined:
    Nov 18, 2014
    Posts:
    9
    Hello i am getting this same error with Unity 2020.3.7f1 and Localization version 1.0.0-pre.10
    In the editor everything works correctly.
    But when i build the app for android then when the application is starting i am getting these errors:

    2021/08/26 19:15:42.785 26348 32328 Error Unity MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[[System.Collections.Generic.IList`1[[UnityEngine.Localization.Locale, Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
    2021/08/26 19:15:42.785 26348 32328 Error Unity at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
    2021/08/26 19:15:42.785 26348 32328 Error Unity at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    2021/08/26 19:15:42.785 26348 32328 Error Unity at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    2021/08/26 19:15:42.785 26348 32328 Error Unity at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in


    And when i try to access the Local count:
    Debug.Log(LocalizationSettings.AvailableLocales.Locales.Count);

    2021/08/26 19:15:52.410 26348 32328 Error Unity Locales PreloadOperation has not been initialized, can not return the available locales.
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.Logger:Log(LogType, Object)
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.Debug:LogError(Object)
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.Localization.Settings.LocalesProvider:get_Locales()
    2021/08/26 19:15:52.410 26348 32328 Error Unity ChangeLanguage:ChangeLanguageButton()
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.Events.InvokableCall:Invoke()
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.Events.UnityEvent:Invoke()
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.UI.Button:press()
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.UI.Button:OnPointerClick(PointerEventData)
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData)
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.EventSystems.StandaloneInputModule:process()
    2021/08/26 19:15:52.410 26348 32328 Error Unity UnityEngine.EventSystems.EventSystem:Update()

    The option managed scripting level is set to low and all the localization files are made addressable.

    What else can i try?
     
  37. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Hi,
    Please try updating to the latest 2020.3 and also try updating the Addressables package.
     
  38. marioshrist

    marioshrist

    Joined:
    Nov 18, 2014
    Posts:
    9
    I have tried to update to the latest version of 2020.3, addressable package is in the latest version 1.18.15.
    but i am also getting the same error, nothing changed with the update to latest 2020.3.
     
  39. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Could you please file a bug report?
     
  40. marioshrist

    marioshrist

    Joined:
    Nov 18, 2014
    Posts:
    9
    I have filed a bug report. Thanks
     
    karl_jones likes this.
  41. gokhan31m

    gokhan31m

    Joined:
    Apr 22, 2021
    Posts:
    10
    marioshrist
    I had the same problem. I solved it by rearranging the project. The problem is due to the settings in this "addressable" Package.
    Reinstalling and Resetting the Settings Was Enough for Me
     
  42. thalesdeluca

    thalesdeluca

    Joined:
    Aug 17, 2021
    Posts:
    1
    I had the same problem. I solved by cleaning up all addressables on Window > Asset Management > Addressables > Group > Build > Clean Build > All and rebuilding the Default Build Script following the documentation right here.

    However, sometimes I need to repeat this process for every build. I'm kinda new to addressables and this package so I don't know if this is fixable just by adjusting the localization package, as it looks like it is a normal process for any addressables. Do not take this last paragraph seriously tho XD
     
  43. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Thats unusual. You should not need to do it every time, only when you change something in localization or change the platform. If you are able to reproduce this issue then do please file a bug so we can look into it.
     
    denis_bogdanov and thalesdeluca like this.
  44. denis_bogdanov

    denis_bogdanov

    Joined:
    Apr 20, 2015
    Posts:
    144
    I had the same problem. Sometimes for an understandable reason I have to do rebuild addressables.But I can't reproduce. it It seems to me that some kind of error occurs while loading the project.
     
  45. marioshrist

    marioshrist

    Joined:
    Nov 18, 2014
    Posts:
    9
    I was able to resolve it by following these steps:
    Deleting the Library folder, re-opening the unity project in the latest LTS version, switching build to android and then from Addresables -> Groups i needed to run a new default build script.
    After these steps the localization language change did work on Android.

    But after a few builds on android the error occurred again. But with an addressables new build it was fixed.
     
  46. marioshrist

    marioshrist

    Joined:
    Nov 18, 2014
    Posts:
    9
    Thank you for your reply, this documentation was very helpful.
     
    karl_jones likes this.
  47. mmekies

    mmekies

    Joined:
    Aug 26, 2020
    Posts:
    12
    Hello Karl , Im having a problem with my build. The localization works fine in the player but once the application builds I get this error log :
     

    Attached Files:

  48. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    What version of Unity are you using? I believe this is an old Addressable bug that should be fixed in the latest version.
     
  49. mmekies

    mmekies

    Joined:
    Aug 26, 2020
    Posts:
    12
    2020.3.0f1 engine with the latest addressable package
     
  50. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Thats a really old version, could you try the latest 2020.3.18f1?