Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expo-localization] Exception: Unsupported ISO 3166 country: es_419 #21414

Closed
andresribeiro opened this issue Feb 27, 2023 · 21 comments · Fixed by #22003 or #27250
Closed

[expo-localization] Exception: Unsupported ISO 3166 country: es_419 #21414

andresribeiro opened this issue Feb 27, 2023 · 21 comments · Fixed by #22003 or #27250

Comments

@andresribeiro
Copy link
Contributor

Minimal reproducible example

https://gist.github.com/andresribeiro/569e4d70afe1778e8f2541e301433017

Summary

The following error appears on Play Console pre-launch report:

Exception com.facebook.react.common.JavascriptException: Error: Call to function 'ExpoLocalization.getLocales' has been rejected.
→ Caused by: java.lang.IllegalArgumentException: Unsupported ISO 3166 country: es_419, js engine: hermes, stack:
_construct@1:105491
Wrapper@1:105136
_createSuperInternal@1:645189
CodedError@1:645474
findBestAvailableLanguage@1:703297
getBestAvailableLanguage@1:703599
setBestAvailableDayJsLocale@1:692514
anonymous@1:692458
loadModuleImplementation@1:73062
guardedLoadModule@1:72611
metroRequire@1:72239
anonymous@1:690154
loadModuleImplementation@1:73062
guardedLoadModule@1:72611
metroRequire@1:72239
anonymous@1:79390
loadModuleImplementation@1:73062
guardedLoadModule@1:72568
metroRequire@1:72239
global@1:71823
  at com.facebook.react.modules.core.ExceptionsManagerModule.reportException (ExceptionsManagerModule.java:72)
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loop (Looper.java:223)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  at java.lang.Thread.run (Thread.java:923)

It might be related to these 2 issues from react-native-localize:

zoontek/react-native-localize#31
zoontek/react-native-localize#36

Environment

System:
OS: Linux 5.4 Linux Mint 20.3 (Una)
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 19.7.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 9.5.0 - /usr/bin/npm
Watchman: 2022060.192726.0 - /usr/local/bin/watchman
npmPackages:
expo: ~48.0.4 => 48.0.4
react: 18.2.0 => 18.2.0
react-native: 0.71.3 => 0.71.3
npmGlobalPackages:
eas-cli: 3.7.2
expo-cli: 6.3.2
Expo Workflow: managed

@andresribeiro andresribeiro added the needs validation Issue needs to be validated label Feb 27, 2023
@brentvatne
Copy link
Member

@andresribeiro - that isn't a valid reproducible example, you should share a link to a repository that we can clone and run and see this issue. it'd be helpful if you can add that to this issue.

that said, it seems that there may be an additional case that we need to handle with getLocales(). @aleqsio - is there enough information here for you to go off of?

@brentvatne brentvatne added needs review Issue is ready to be reviewed by a maintainer Localization and removed needs validation Issue needs to be validated labels Feb 27, 2023
@aleqsio
Copy link
Contributor

aleqsio commented Feb 27, 2023

yeah, should be enough.

@aleqsio aleqsio self-assigned this Feb 27, 2023
@aleqsio aleqsio added Issue accepted and removed needs review Issue is ready to be reviewed by a maintainer labels Feb 27, 2023
@expo-bot
Copy link
Collaborator

Thank you for filing this issue!
This comment acknowledges we believe this may be a bug and there’s enough information to investigate it.
However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

@andresribeiro
Copy link
Contributor Author

@brentvatne I recognize that it's not a valid reproducible example, but there is no way to provide one since it is just calling getLocales() on a device where the language does not have a country code (according to the react-native-localize issues)

@grzegorz-krzeminski
Copy link

Have same issue on Expo 47:

Exception com.facebook.react.common.JavascriptException: Error: Call to function 'ExpoLocalization.getLocales' has been rejected.
→ Caused by: java.lang.IllegalArgumentException: Unsupported ISO 3166 country: ar, js engine: hermes, stack:
_construct@1:153179
Wrapper@1:152824
_createSuperInternal@1:607368
CodedError@1:607653
anonymous@1:1755898
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1753927
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1753586
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1753475
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1752731
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1750784
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1750404
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1750281
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1750167
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1747243
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1746578
metroRequire@1:55984
anonymous@1:1191421
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1151148
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:1150957
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:679976
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:679750
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:669949
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:651969
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:651821
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:651679
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:651598
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:651491
loadModuleImplementation@1:56807
guardedLoadModule@1:56356
metroRequire@1:55984
anonymous@1:63189
loadModuleImplementation@1:56807
guardedLoadModule@1:56313
metroRequire@1:55984
global@1:55559
  at com.facebook.react.modules.core.ExceptionsManagerModule.reportException (ExceptionsManagerModule.java:72)
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:883)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loop (Looper.java:237)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  at java.lang.Thread.run (Thread.java:919)

@MortensenC
Copy link

Same issue here for ar EXPO 48:

Exception com.facebook.react.common.JavascriptException: Error: Call to function 'ExpoLocalization.getLocales' has been rejected.
→ Caused by: java.lang.IllegalArgumentException: Unsupported ISO 3166 country: ar, js engine: hermes, stack:
_construct@1:126614
Wrapper@1:126259
_createSuperInternal@1:668274
CodedError@1:668559
_handleAppStateChange@1:2231905
anonymous@1:645128
emit@1:115114
__callFunction@1:120571
anonymous@1:119079
__guard@1:120018
callFunctionReturnFlushedQueue@1:119037
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException (ExceptionsManagerModule.java:72)
at java.lang.reflect.Method.invoke
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
at com.facebook.jni.NativeRunnable.run
at android.os.Handler.handleCallback (Handler.java:942)
at android.os.Handler.dispatchMessage (Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
at android.os.Looper.loopOnce (Looper.java:201)
at android.os.Looper.loop (Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
at java.lang.Thread.run (Thread.java:1012)

image

@Alan-Graton
Copy link

Alan-Graton commented Sep 14, 2023

@MortensenC Still having this error? I'm also using Expo V48 and just send my build to Play Store, but in my case the locale was es_419

@MiguelFFuentes
Copy link

@aleqsio @MortensenC Same here, we just got the error with es_419 locale.

@emilnili
Copy link

emilnili commented Sep 26, 2023

Getting these errors as well. With expo 49. Causes crashes for android devices reported in google play.

Error: Call to function 'ExpoLocalization.getLocales' has been rejected. → Caused by: java.lang.IllegalArgumentException: Unsupported ISO 3166 country: en

@andresribeiro
Copy link
Contributor Author

@aleqsio can you reopen this issue, please?

@aleqsio aleqsio reopened this Sep 26, 2023
@Alan-Graton
Copy link

Will Play Store deny my production deploy while I'm having this issue?

@MortensenC
Copy link

MortensenC commented Sep 27, 2023 via email

@andresribeiro
Copy link
Contributor Author

Will Play Store deny my production deploy while I'm having this issue?

no.

@cgordon-d2l
Copy link

We are having this problem as well. These are the observations I've made so far about the issue:

  • It seems that the country code is missing or not an ISO country code for the exceptions we're getting. Example: es_IC, en, pl_SP, es_419, nl, ar_XB
  • The country code is supposed to be optional, but it looks like Java throws an exception if it's missing or incorrect
  • There was a similar error for react-native-localize Issue 31, and the fix was to add a check to validate the country code

Perhaps a similar check is needed here?

@Voznov
Copy link

Voznov commented Oct 19, 2023

Same problem: Unsupported ISO 3166 country: en

@Alexandr1992
Copy link

Same problem: Unsupported ISO 3166 country: ar

@Alan-Graton
Copy link

Still no solution for this?

@cgordon-d2l
Copy link

We were using expo-localization 14.0.0 and seeing this error. A fix to catch exceptions has been added for v14.2.0

If you're still seeing this problem, perhaps try upgrading to expo-localization v14.2.0 or higher and see if that solves it?

@Voznov
Copy link

Voznov commented Dec 20, 2023

@cgordon-d2l We are facing with this error on 14.5.0. I checked 14.0.0-14.2.0 diff and 14.2.0-14.5.0 diff and didn't find any solid changes. So for me it's a mystery why it's working for you and not working for us. Our firebase crashlytics shows that there is no difference between lib versions, os versions or device models

@newfylox
Copy link

newfylox commented Feb 21, 2024

It's hard to provide a reproducible example, but I decided to run an emulator, which let me change the locale through adb commands. The faulty locale is named Latin American Spanish but I was not able to see this option through the settings UI. I guess some phones are shipped with this option enabled or added on custom Android OS phones.

Using an emulator let me change this in terminal. So I decided to test it on an old Android version (11) by running these commands

adb root
adb shell "setprop persist.sys.locale es-419; setprop ctl.restart zygote"

Navigating to the language setting, I can finally see that option, which wasn't available before, and that my phone is using Latin American Spanish

2024-02-16_15-14

Now I did 2 different console.log, one with the deprecated locale constant and one with the new getLocales() method. The deprecated one is correctly showing the locale but not the new one, showing an empty array. And so my code was using getLocales() method in both example after these 2 different logs, hence crashing my application

2024-02-16_15-14_1
2024-02-16_15-13

Sad because it's even included in documentation examples

export type Locale = {
/**
* An [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) with a region code.
* @example
* `'en-US'`, `'es-419'`, `'pl-PL'`.
*/
languageTag: string;

@aleqsio
Copy link
Contributor

aleqsio commented Feb 22, 2024

@newfylox i'll try to follow those steps and see if I can reproduce – seems to be a fairly good repro, thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet