Localization package not load on device despite buildings addressables

Hi,
I’m stuck with that bug since 2 hours now. I can’t understand where it come form. I build for android.
What I did :

  • Installed the 0.9 preview from GIT
  • Created my locales
  • Created my string table
  • Build my addressable from group > build > new build > default build script
    The normal procedure that I’ve done several times and worked each time.

Everything works into the editor. But when I launch the app on android device, my localeSelected var is not assigned and something goes wrong with AvailableLocales.Locales.Count because this value is never assigned too.

localeSelected var is assigned by this script :

public void FindLocale(){
        for(int i = 0; i < UnityEngine.Localization.Settings.LocalizationSettings.AvailableLocales.Locales.Count; i++)
        {
            var locale = UnityEngine.Localization.Settings.LocalizationSettings.AvailableLocales.Locales[i];
            if (UnityEngine.Localization.Settings.LocalizationSettings.SelectedLocale == locale){
                localeSelected = i;
            }
        }
    }

I call this function when a transition is done (3s after launching the app) I tried to delay it to 20s but nothing changes, so it is why i am stuck. I also tried resetting packages to default but doesn’t help too.

@karl_jones any suggestion ?

Could you try the Locale selector sample that comes with the package? Its in the package manager.
Do you have any errors in the log?

Hello Karl thank you for replying.
I am a bit late but i didn’t use logcat until now so here are the logs :

2021/01/20 00:49:40.705 23263 23305 Error Unity Purchasing failed to initialize. Reason: NoProductsAvailable
2021/01/20 00:49:40.705 23263 23305 Error Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2021/01/20 00:49:40.705 23263 23305 Error Unity
2021/01/20 00:49:54.455 23263 23305 Error Unity Locales PreloadOperation has not been initialized, can not return the available locales.
2021/01/20 00:49:54.455 23263 23305 Error Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2021/01/20 00:49:54.455 23263 23305 Error Unity
2021/01/20 00:49:54.465 23263 23305 Error Unity NullReferenceException: Object reference not set to an instance of an object.
2021/01/20 00:49:54.465 23263 23305 Error Unity (Filename: currently not available on il2cpp Line: -1)

Tell me if something is missing. I did not use strip engine and use iap / ads packages too.

I just google the Peoload Operation error and saw this thread :

As you said, it seems to be a bug in the package not still solved at the moment, am i right ?

If yes, do you have an idea on how to avoid this error ? I just need the locale used by the System locale Selector to load different files from the Resources asset folder once in the game.

No that error is due to stripping, if you have stripping disabled then it’s not that.
It sounds like you are trying to access the locales before they have loaded, you need to wait for the preloading operation to complete. Take a look at the samples we have, the locale selector menu should give you an idea.

Okay so problem solved.
You were right, I used the code provided in the sample.
Here is how I modified it :

public void FindLocale(){
        m_InitializeOperation = UnityEngine.Localization.Settings.LocalizationSettings.SelectedLocaleAsync;
        if (m_InitializeOperation.IsDone)
        {
            for(int i = 0; i < UnityEngine.Localization.Settings.LocalizationSettings.AvailableLocales.Locales.Count; i++){
                var locale = UnityEngine.Localization.Settings.LocalizationSettings.AvailableLocales.Locales[i];
                if (UnityEngine.Localization.Settings.LocalizationSettings.SelectedLocale == locale){
                    localeSelected = i;
                }
            }
        }
        else
        {
            return;
        }
       
    }

This function is called while the localeSelected ==-1 (assigned in the Start method).
Thank you for your help.

1 Like