Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intl.numberformat in React native works fine when running in ios but not in android

I am developing an app with React Native to run on IOS and Android. I use Intl.numberformat() to print currency, and it works smoothly when the app runs on IOS, but I get this error when running on Android: ReferenceError: Can't find variable: Intl.

How can I make it run in both plataforms?

like image 946
HuLu ViCa Avatar asked Mar 02 '23 02:03

HuLu ViCa


1 Answers

I had faced similar issue. The issue was with Javascript core which runs the react- native. There are two ways to overcome this.

1.Method 1 You'll have to integrate latest javascript core into your android build or upgrade react native to 0.59

You can find it here

  1. Method 2 Add or override the following code in your app/build.gradle

def jscFlavor = 'org.webkit:android-jsc-intl:+'

Clean build and react-native run android

like image 125
Akshay Shenoy Avatar answered Mar 05 '23 14:03

Akshay Shenoy