React-native: com.facebook.react.common.JavascriptException: Can't find variable: Intl

Created on 14 May 2018  路  15Comments  路  Source: facebook/react-native

My debug builds are working perfectly fine, however, when trying to use a production build, the apk(Android) crashes with this error: com.facebook.react.common.JavascriptException: Can't find variable: Intl, stack:

Here's the full stack trace:

05-14 16:33:42.145 18137 18176 E AndroidRuntime: com.facebook.react.common.JavascriptException: Can't find variable: Intl, stack:
05-14 16:33:42.145 18137 18176 E AndroidRuntime: <unknown>@488:88
05-14 16:33:42.145 18137 18176 E AndroidRuntime: d@2:768
05-14 16:33:42.145 18137 18176 E AndroidRuntime: n@2:409
05-14 16:33:42.145 18137 18176 E AndroidRuntime: t@2:262
05-14 16:33:42.145 18137 18176 E AndroidRuntime: <unknown>@487:171
05-14 16:33:42.145 18137 18176 E AndroidRuntime: d@2:768
05-14 16:33:42.145 18137 18176 E AndroidRuntime: n@2:409
05-14 16:33:42.145 18137 18176 E AndroidRuntime: t@2:262
05-14 16:33:42.145 18137 18176 E AndroidRuntime: <unknown>@484:191
05-14 16:33:42.145 18137 18176 E AndroidRuntime: d@2:768
05-14 16:33:42.145 18137 18176 E AndroidRuntime: n@2:409
05-14 16:33:42.145 18137 18176 E AndroidRuntime: t@2:262
05-14 16:33:42.145 18137 18176 E AndroidRuntime: <unknown>@306:411
05-14 16:33:42.145 18137 18176 E AndroidRuntime: d@2:768
05-14 16:33:42.145 18137 18176 E AndroidRuntime: n@2:409
05-14 16:33:42.145 18137 18176 E AndroidRuntime: t@2:262
05-14 16:33:42.145 18137 18176 E AndroidRuntime: <unknown>@12:42
05-14 16:33:42.145 18137 18176 E AndroidRuntime: d@2:768
05-14 16:33:42.145 18137 18176 E AndroidRuntime: n@2:339
05-14 16:33:42.145 18137 18176 E AndroidRuntime: t@2:262
05-14 16:33:42.145 18137 18176 E AndroidRuntime: global code@509:8
05-14 16:33:42.145 18137 18176 E AndroidRuntime: 
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:746)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:95)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
05-14 16:33:42.145 18137 18176 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)

Environment

Environment:
OS: macOS High Sierra 10.13.3
Node: 10.0.0
Yarn: Not Found
npm: 6.0.0
Watchman: Not Found
Xcode: Xcode 9.3.1 Build version 9E501
Android Studio: 3.1 AI-173.4720617

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

Steps to Reproduce

Run ./gradlew assembleRelease, and start the app. The app crashes.

Expected Behavior

The should start just like it does in debug mode

Actual Behavior

The app crashes. There is no Intl in use in the bundle file generated

Bug Follow Up Android Locked

Most helpful comment

This will actually be fully supported in 0.60 through https://github.com/facebook/react-native/pull/24276 which adds a build flag to swap out JSC for Android.

All 15 comments

The JavaScript runtime on Android does not have the Intl APIs. For Android, you'll need to include a polyfill (https://github.com/andyearnshaw/Intl.js/). Also not all JS runtimes on iOS have Intl. I think iOS 8 and 9 also require the polyfill.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

I'm having a similar issue. Same setup but error is

08-14 22:34:30.059 23358 23399 E AndroidRuntime: com.facebook.react.common.JavascriptException: Can't find variable: o, stack:
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:268180
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:290439
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:293683
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:173692
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:206617
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:473707
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:475967
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:560286
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:561006
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:560116
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:559455
08-14 22:34:30.059 23358 23399 E AndroidRuntime: r@1797:148
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:493
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1797:504
08-14 22:34:30.059 23358 23399 E AndroidRuntime: c@2:809
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1635:236
08-14 22:34:30.059 23358 23399 E AndroidRuntime: c@2:809
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1634:98
08-14 22:34:30.059 23358 23399 E AndroidRuntime: c@2:809
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@1632:256
08-14 22:34:30.059 23358 23399 E AndroidRuntime: c@2:809
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@652:601
08-14 22:34:30.059 23358 23399 E AndroidRuntime: c@2:809
08-14 22:34:30.059 23358 23399 E AndroidRuntime: <unknown>@12:85
08-14 22:34:30.059 23358 23399 E AndroidRuntime: c@2:809
08-14 22:34:30.059 23358 23399 E AndroidRuntime: i@2:381
08-14 22:34:30.059 23358 23399 E AndroidRuntime: global code@2876:8
08-14 22:34:30.059 23358 23399 E AndroidRuntime: 
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:790)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:164)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
08-14 22:34:30.059 23358 23399 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:764)

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

I believe this feature request is still valid

Should be fixed with 0.59 and new Javascript Core
@heroic can you test it to confirm or deny?

Upgraded to latest react native, but still getting the error on Intl. Also toLocaleString is not doing formatting.

react-native-cli: 2.0.1
react-native: 0.59.1

_new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR',useGrouping: true }).format(price)}_

_price.toLocaleString('en-IN', { style: 'currency', currency: 'INR',useGrouping: true })_

This should definitely be fixed with 0.59 and the latest JSC.

@cpojer I upgraded to React-Native 0.59.2 but there's still no support for Intl on Android.

Screenshot_1553790587

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 314.12 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.0 - /var/folders/72/hzvg960s14db828r10szzy180000gn/T/yarn--1553790622058-0.447480170807119/node
      Yarn: 1.15.2 - /var/folders/72/hzvg960s14db828r10szzy180000gn/T/yarn--1553790622058-0.447480170807119/yarn
      npm: 6.4.1 - ~/Code/nightingale-mobile/node_modules/.bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        Build Tools: 28.0.3
        API Levels: 28
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5314842
      Xcode: 10.2/10E125 - /usr/bin/xcodebuild
    npmPackages:
      @types/react: 16.7.20 => 16.7.20 
      @types/react-native: 0.57.29 => 0.57.29 
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.2 => 0.59.2 

@cpojer

This should definitely be fixed with 0.59 and the latest JSC.

I'm almost certain that 0.59 uses the non-international variant of the JSC, which means that this is still an issue. Using the International variant was discussed shortly here but there's no record of the final decision.

Maybe it's worth to consider adding a gradle flag (addInternationalSupport) for users that need the Intl features (I believe it's quite common in mobile apps)?

React Native uses precompiled versions of JSC. This is not in the main repo but rather in a community repo: https://github.com/react-native-community/jsc-android-buildscripts

It's probably best to bring it up there.

@cpojer the community repo has a JSC variant that supports Intl and it is very well documented. There's absolutely no point bringing issue there. It's just the React Native team not adopting the international variant JSC, and insisting Intl issue had already been fixed in RN 0.59, which is apparently false.

This will actually be fully supported in 0.60 through https://github.com/facebook/react-native/pull/24276 which adds a build flag to swap out JSC for Android.

After upgrade to React-Native 0.59.9, issue come at time of launchig the app.
com.facebook.react.common.JavascriptException: Can't find variable: width, stack:

Please help me out

I'm running react native 0.61.5 and still not supports.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phongyewtong picture phongyewtong  路  3Comments

anchetaWern picture anchetaWern  路  3Comments

despairblue picture despairblue  路  3Comments

jlongster picture jlongster  路  3Comments

axelg12 picture axelg12  路  3Comments