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

com.facebook.react.common.JavascriptException: Can't find variable: Intl #19251

Closed
3 tasks done
heroic opened this issue May 14, 2018 · 15 comments
Closed
3 tasks done

com.facebook.react.common.JavascriptException: Can't find variable: Intl #19251

heroic opened this issue May 14, 2018 · 15 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@heroic
Copy link

heroic commented May 14, 2018

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

@react-native-bot react-native-bot added the Platform: Android Android applications. label May 14, 2018
@newyankeecodeshop
Copy link
Contributor

newyankeecodeshop commented May 16, 2018

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.

@stale
Copy link

stale bot commented Aug 14, 2018

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 14, 2018
@paullinator
Copy link

paullinator commented Aug 15, 2018

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)

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 15, 2018
@stale
Copy link

stale bot commented Nov 13, 2018

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 13, 2018
@gianpaj
Copy link

gianpaj commented Nov 13, 2018

I believe this feature request is still valid

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 13, 2018
@hramos hramos removed the Bug Report label Feb 6, 2019
@radeno
Copy link
Contributor

radeno commented Mar 14, 2019

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

@SandeepThomas
Copy link

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 })

@cpojer
Copy link
Contributor

cpojer commented Mar 26, 2019

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

@cpojer cpojer closed this as completed Mar 26, 2019
@leethree
Copy link

@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 

@erandagan
Copy link

@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)?

@cpojer
Copy link
Contributor

cpojer commented Apr 1, 2019

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.

@leethree
Copy link

leethree commented Apr 1, 2019

@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.

@cpojer
Copy link
Contributor

cpojer commented Apr 3, 2019

This will actually be fully supported in 0.60 through #24276 which adds a build flag to swap out JSC for Android.

@rggupta72
Copy link

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

@wallace-sf
Copy link

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

@facebook facebook locked as resolved and limited conversation to collaborators Mar 26, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests