Search Unity

Android and LocalizationSettings.SelectedLocale

Discussion in 'Localization Tools' started by Alexis-Dev, Jan 28, 2020.

  1. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
  2. gerokristof

    gerokristof

    Joined:
    Oct 31, 2018
    Posts:
    1
    How can I build the addressables?
     
  3. EKO_LX

    EKO_LX

    Joined:
    Dec 25, 2020
    Posts:
    45
    gerokristof and karl_jones like this.
  4. EKO_LX

    EKO_LX

    Joined:
    Dec 25, 2020
    Posts:
    45
    I updated my version of Unity to 2020.3.0f1 and built the addressables for Mac. When I launch the game I get following in log:

    Exception encountered in operation Resource<IAssetBundleResource>(localization-locales_assets_all.bundle), status=Failed, result= : Invalid path in AssetBundleProvider: 'Library/com.unity.addressables/aa/OSX/StandaloneOSX/localization-locales_assets_all.bundle'.

    Exception encountered in operation Dependencies [localization-locales_assets_all.bundle...], status=Failed, result=System.Collections.Generic.List`1[UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle] : Invalid path in AssetBundleProvider: 'Library/com.unity.addressables/aa/OSX/StandaloneOSX/localization-locales_assets_all.bundle'.

    Exception encountered in operation Resource<Locale>(English (en).asset), status=Failed, result= : Dependency Exception

    Exception encountered in operation Resource<IAssetBundleResource>(localization-locales_assets_all.bundle), status=Failed, result= : Invalid path in AssetBundleProvider: 'Library/com.unity.addressables/aa/OSX/StandaloneOSX/localization-locales_assets_all.bundle'.

    Exception encountered in operation Dependencies [localization-locales_assets_all.bundle...], status=Failed, result=System.Collections.Generic.List`1[UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle] : Invalid path in AssetBundleProvider: 'Library/com.unity.addressables/aa/OSX/StandaloneOSX/localization-locales_assets_all.bundle'.

    Exception encountered in operation Resource<Locale>(Russian (ru).asset), status=Failed, result= : Dependency Exception

    Exception encountered in operation Dependencies [English (en).asset..., Russian (ru).asset...], status=Failed, result=System.Collections.Generic.List`1[UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle] : Dependency Exception

    Exception encountered in operation CompletedOperation, status=Failed, result= : Dependency Exception

    Exception encountered in operation ChainOperation<IList`1> - Dependencies, status=Failed, result= : ChainOperation of Type: System.Collections.Generic.IList`1[UnityEngine.Localization.Locale] failed because dependent operation failed
    Dependency Exception

    Exception encountered in operation ChainOperation<IList`1> - InitializationOperation, status=Failed, result= : ChainOperation of Type: System.Collections.Generic.IList`1[UnityEngine.Localization.Locale] failed because dependent operation failed
    ChainOperation of Type: System.Collections.Generic.IList`1[UnityEngine.Localization.Locale] failed because dependent operation failed
    Dependency Exception

    No Locale could be selected:
    No Locales were available. Did you build the Addressables?
    The following (2) IStartupLocaleSelectors were used:
    UnityEngine.Localization.Settings.CommandLineLocaleSelector
    UnityEngine.Localization.Settings.SpecificLocaleSelector

    No Locale could be selected:
    No Locales were available. Did you build the Addressables?
    The following (2) IStartupLocaleSelectors were used:
    UnityEngine.Localization.Settings.CommandLineLocaleSelector
    UnityEngine.Localization.Settings.SpecificLocaleSelector

    Can not preload when `LocalizationSettings.SelectedLocale` is null.

    No Locale could be selected:
    No Locales were available. Did you build the Addressables?
    The following (2) IStartupLocaleSelectors were used:
    UnityEngine.Localization.Settings.CommandLineLocaleSelector
    UnityEngine.Localization.Settings.SpecificLocaleSelector

    Can not preload when `LocalizationSettings.SelectedLocale` is null.

    Unloading 7 Unused Serialized files (Serialized files now loaded: 0)
    UnloadTime: 14.031644 ms
    Exception encountered in operation CompletedOperation, status=Failed, result= : SelectedLocale is null

    Exception encountered in operation UnityEngine.Localization.GetTableEntryOperation`2[UnityEngine.Localization.Tables.StringTable,UnityEngine.Localization.Tables.StringTableEntry], result='', status='Failed', status=Failed, result=UnityEngine.Localization.Settings.LocalizedDatabase`2+TableEntryResult[[UnityEngine.Localization.Tables.StringTable, Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[UnityEngine.Localization.Tables.StringTableEntry, Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] : SelectedLocale is null

    Exception encountered in operation CompletedOperation, status=Failed, result= : SelectedLocale is null

    I removed the addressables_content_state and build it again, same issue.
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    This looks like a known bug in Addressables. Its using the wrong path.
    See step 4 here as a workaround
    https://forum.unity.com/threads/troubleshooting-addressables-issues.1060346/
     
  6. EKO_LX

    EKO_LX

    Joined:
    Dec 25, 2020
    Posts:
    45
    karl_jones likes this.
  7. vasilevcvtn

    vasilevcvtn

    Joined:
    Dec 4, 2019
    Posts:
    1
    Hello,

    I have a problem with localization when building for iOS. In my project I have a button that changes between to languages. For Android everything works perfectly, but for iOS nothing happens when the button is pressed. What could be the problem?

    Thanks!
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    Do you have any error messages?
     
  9. Giampy_Normo

    Giampy_Normo

    Joined:
    Jun 19, 2021
    Posts:
    2
    Hi everyone, i'm new there i started using Localisation and im aveing some issues.
    this is my settings for localisation, when i install the app on my phone (android) doesn't take the lang from the phone and start with the default language.
    some advice?
     

    Attached Files:

  10. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    Hello, I can't figure out what's wrong. Changing the language does not work for android. Here is my code, Everything works in the editor, but when I download the game to the phone and try to call ChangeLanguage(1) (1 is the Russian language), the language does not change as the editor
    upload_2021-12-2_12-48-0.png
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    Do you get any errors? What happens?
     
  12. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    Logcat is not available at the moment, but Crashlytics in firebase outputs the following. Would that help?

    Non-fatal Exception: java.lang.Exception: 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]]
    at System.RuntimeType.CreateInstanceMono(System.RuntimeType)
    at System.Activator.CreateInstance(System.Activator)
    at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New(UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy)
    at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T](UnityEngine.ResourceManagement.ResourceManager)
    at UnityEngine.ResourceManagement.ResourceManager.CreateCompletedOperationInternal[TObject](UnityEngine.ResourceManagement.ResourceManager)
    at UnityEngine.ResourceManagement.ResourceManager.CreateCompletedOperationWithException[TObject](UnityEngine.ResourceManagement.ResourceManager)
    at UnityEngine.AddressableAssets.AddressablesImpl.LoadAssetsAsync[TObject](UnityEngine.AddressableAssets.AddressablesImpl)
    at UnityEngine.AddressableAssets.AddressablesImpl+<>c__DisplayClass87_0`1[TObject].<LoadAssetsWithChain>b__0(UnityEngine.AddressableAssets.AddressablesImpl+<>c__DisplayClass87_0`1[TObject])
    at System.Func`2[T,TResult].Invoke(System.Func`2[T,TResult])
    at UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject].Execute(UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject])
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject])
    at UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject].InvokeWaitForCompletion(UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject])
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject])
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle.WaitForCompletion(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle)
    at UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject].InvokeWaitForCompletion(UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1[TObject])
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].WaitForCompletion(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject])
    at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].WaitForCompletion(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject])
    at UnityEngine.Localization.Settings.LocalizationSettings.GetSelectedLocale(UnityEngine.Localization.Settings.LocalizationSettings)
    at Language.ChangeLanguage(Language)
    at UnityEngine.Events.UnityAction.Invoke(UnityEngine.Events.UnityAction)
    at UnityEngine.Events.UnityEvent`1[T0].Invoke(UnityEngine.Events.UnityEvent`1[T0])
    at UnityEngine.UI.Dropdown.OnSelectItem(UnityEngine.UI.Dropdown)
    at UnityEngine.Events.UnityAction`1[T0].Invoke(UnityEngine.Events.UnityAction`1[T0])
    at UnityEngine.Events.UnityEvent`1[T0].Invoke(UnityEngine.Events.UnityEvent`1[T0])
    at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke(UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1])
    at UnityEngine.EventSystems.ExecuteEvents.Execute[T](UnityEngine.EventSystems.ExecuteEvents)
    at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress(UnityEngine.EventSystems.StandaloneInputModule)
    at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents(UnityEngine.EventSystems.StandaloneInputModule)
    at UnityEngine.EventSystems.StandaloneInputModule.Process(UnityEngine.EventSystems.StandaloneInputModule)
    at UnityEngine.EventSystems.StandaloneInputModule:process(UnityEngine.EventSystems)
     
  13. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    I got 11 errors. Nine of them were as I sent in and two of them were Index was out of range.
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    Yes that helps. This error:

    MissingMethodException : Default constructor not found for type UnityEngine.ResourceManagement.ResourceManager+CompletedOperation


    is an old bug that should be fixed by updating to the latest patch version. Could you please try and update to the latest patch version? Also the latest Localization package version if you are not already on 1.0.5 and finally the latest Addressables package version 1.19.11
     
  15. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    trouble :( Unity last 2020 version too. But I didn't understand what the latest patch version. What exactly?
    upload_2021-12-2_13-57-18.png
     
  16. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
  17. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    2020.3.23f1
    I can also try to build the game on earlier versions of.
     
  18. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
  19. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    1. Try disabling code stripping
    it's Strip Engine Code?
    upload_2021-12-2_14-19-20.png
     
  20. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    Yes but that looks fine, low level stripping has never been an issue before, just medium and high although that should be fixed now.
     
  21. kenor_brooks

    kenor_brooks

    Joined:
    Jun 4, 2020
    Posts:
    46
    I do: Window->Asset management->Addressables->Groups. Build->Clen Build->All. Build->New Build -> Default.
    And it all worked. It's strange, I used to get errors during this.
    Спасибо
     
    karl_jones likes this.
  22. dingqun2020

    dingqun2020

    Joined:
    Dec 30, 2020
    Posts:
    2
    In my case the Application.systemLanguage = "zh-hans" on my 2 android test phones, Huawei Mate40 Pro & Redmi K30 Pro. But the available locale contains "zh-Hans".
    The H is in upper case. So the GetLocale return null because it checking with equal() function.
    Is there any way I can change the checking ?
     
  23. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    What version are you using? In 1.1.1 we added case insensitive checks to GetLocale to handle this very issue.
    If its still happening in 1.1.1 then please file a bug report.
     
    dingqun2020 likes this.
  24. dingqun2020

    dingqun2020

    Joined:
    Dec 30, 2020
    Posts:
    2
    I was using 1.0.5. After upgraded to 1.1.1, it works now. thanks you.
     
    karl_jones likes this.
  25. jhr2013

    jhr2013

    Joined:
    Sep 25, 2020
    Posts:
    4
    How to check child locale belongs to parent locale in script?
     
  26. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,293
    We don't really have a parent-child relationship between Locales. Locales can have fallbacks, this can come from adding fallback metadata to a Locale or can come from querying the CultureInfo for that locale.
    So if you wanted to find out what locales may reference this Locale you could iterate through the locales and call GetFallbacks to see if that Locale was in the fallback list. You could also try and build a graph from all of this information to make it easier to figure out the relationships.
    What are you trying to do? Why do you need to know the parent locale?