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

**URL:** <https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963>\
**Category:** Support\
**Created:** [October 29, 2024, 8:37am UTC](https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963 "2024-10-29T08:37:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrZigaS](https://discuss.appium.io/user_avatar/discuss.appium.io/mrzigas/32/14173_2.png) [@MrZigaS](https://discuss.appium.io/u/MrZigaS)\
**Post date:** [October 29, 2024, 8:37am UTC](https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963/1 "2024-10-29T08:37:59Z")

</div>

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. 🤔  
I tried using UiAutomator2Options and set the locale and language by:

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

```

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

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

```

…but the error is the same.

Any idea why this is happening?

---

<div class="post-metadata">

**Author:** ![wreed](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/919ad9/32.png) [@wreed](https://discuss.appium.io/u/wreed)\
**Post date:** [October 29, 2024, 3:37pm UTC](https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963/2 "2024-10-29T15:37:16Z")

</div>

I think you are seeing this:

> <https://github.com/appium/java-client/issues/2184>
>
> \## Description
> 
> We are noticing that in 9.2.3, the java client is no more appe…nding prefix 'appium:' to the capabilities when we set those using DesiredCapabilities class. Is this intentional or a bug?
> 
> \## Environment
> 
> \* Java client build version or git revision if you use some snapshot: 9.2.3
> \* Appium server version or git revision if you use some snapshot: Latest
> \* Desktop OS/version used to run Appium if necessary: Mac OS
> \* Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 21
> \* Mobile platform/version under test: Android 14
> \* Real device or emulator/simulator: Both
> 
> \## Code To Reproduce Issue \[Good To Have \]
> 
> Set capabilities as well and try to create a driver session:
> 
> \`\`\`
> DesiredCapabilities caps =new DesiredCapabilities();
> caps.setCapability("platformName", "Android");
> caps.setCapability("deviceName", "device\_name");
> caps.setCapability("automationName", "UiAutomator2");
> caps.setCapability("udid", "emulator-5554");
> caps.setCapability("app", "file\_path");
> \`\`\`
> 
> \## Exception Stacktraces
> 
> You can see in the exception trace, the client hasn't appended 'appium:' prefix to the capabilities.
> 
> Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'name', ip: 'ip'Build info: version: '4.21.0', revision: '79ed462ef4'System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '17.0.8'Driver info: io.appium.java\_client.android.AndroidDriverCommand: \[null, newSession {capabilities=\[Capabilities {app: /file\_path..., automationName: UiAutomator2, deviceName:device\_name, platformName: ANDROID, udid: emulator-5554}\]}\]Capabilities {app: /file\_path..., automationName: UiAutomator2, deviceName:device\_name, platformName: ANDROID, udid: emulator-5554} at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536) at io.appium.java\_client.AppiumDriver.startSession(AppiumDriver.java:270) at org.openqa.selenium.remote.RemoteWebDriver.\<init\>(RemoteWebDriver.java:161) at io.appium.java\_client.AppiumDriver.\<init\>(AppiumDriver.java:91) at io.appium.java\_client.AppiumDriver.\<init\>(AppiumDriver.java:103) at io.appium.java\_client.android.AndroidDriver.\<init\>(AndroidDriver.java:109) at \[sampleoad.run\](https://sampleoad.run/).main(run.java:33)Caused by: \*\*java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: \[app, automationName, deviceName, udid\]\*\* at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$5(NewSessionPayload.java:163) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:540) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at org.openqa.selenium.remote.NewSessionPayload.validate(NewSessionPayload.java:167) at org.openqa.selenium.remote.NewSessionPayload.\<init\>(NewSessionPayload.java:70) at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:99) at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:84) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:60) at io.appium.java\_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:176)
> 
> \## Link To Appium Logs
> 
> The client errors out before sending the request to the server.

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

> **[GitHub - appium/java-client: Java language binding for writing Appium Tests,...](https://github.com/appium/java-client?tab=readme-ov-file#usage-examples)**
>
> Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol

---

<div class="post-metadata">

**Author:** ![mykola-mokhnach](https://discuss.appium.io/user_avatar/discuss.appium.io/mykola-mokhnach/32/4578_2.png) [@mykola-mokhnach](https://discuss.appium.io/u/mykola-mokhnach)\
**Post date:** [October 30, 2024, 7:09am UTC](https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963/3 "2024-10-30T07:09:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MrZigaS](https://discuss.appium.io/user_avatar/discuss.appium.io/mrzigas/32/14173_2.png) [@MrZigaS](https://discuss.appium.io/u/MrZigaS)\
**Post date:** [October 30, 2024, 8:44am UTC](https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963/4 "2024-10-30T08:44:24Z")

</div>

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. 🤷‍♂️

Thx again 👍
