React-Native and Intl polyfill required on Android device
Instead of importing locale-data from react-intl
, I have resolved the issue importing the polyfill and the locale data from intl
Install intl
npm install intl
Add this at the very top of your app:
import 'intl';
import 'intl/locale-data/jsonp/en';
Heads up, this works now with just doing the import 'intl';
at the top and still loading the locale-data from react-intl
. Using the following versions:
"intl": "^1.2.5",
"react-intl": "^2.2.2",
Modifying the "build.gradle"
On android, you can modify the "build.gradle" file inside /android/app/build.gradle. Remember, it is NOT the file in /android/app/gradle/build.gradle.
then, go to the sited file and search for:
/** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+'
now, modify the last line, or simply comment it out and copy and paste the similar one above. And the result will be this:
/** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ //def jscFlavor = 'org.webkit:android-jsc:+' def jscFlavor = 'org.webkit:android-jsc-intl:+'