[Android] Cannot set the device locale to a - You may want to apply one of the following locales instead

Hey,
I have just upgraded from Java client 9.1.0 to 9.3.0 and I had to switch from using DesiredCapabilities to BaseOptions/UiAutomator2Options.

Everything else stays the same, so when I try to run a test on an emulator, I’m getting this error:

Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Cannot set the device locale to ‘it_IT’. You may want to apply one of the following locales instead: ca_IT,de_IT,fur_IT,it_CH,it_IT,it_SM,it_VA

The error is suggesting to use the same locale as I’m actually using. :thinking:
I tried using UiAutomator2Options and set the locale and language by:

options.setLocale("IT")
options.setLanguage("it")

The other try was by using the BaseOptions and setting it like this:

baseOptions.amend(UiAutomator2Options.LANGUAGE_OPTION, "it");
baseOptions.amend(UiAutomator2Options.LOCALE_OPTION, "IT");

…but the error is the same.

Any idea why this is happening?

I think you are seeing this:

Not sure about the locale issue. Are you using UiAutomator2Options like the example on Github?

Please provide the full server log. The device logcat output might also be useful

Thank you both for your replies. @wreed, yeah I checked those and updated the code accordingly.

However, I was about to get the Server logs and record logcat, but today it just magically works. I’m using the same code as in my initial post, I haven’t changed anything.

It might be that I needed to restart my PC for some reason, idk. :man_shrugging:

Thx again :+1:

1 Like