JavaScriptCore for Android (React Native)
jsc-android provides pre-built versions of JavaScriptCore (JSC) for integration into React Native applications running on the Android platform. It is a critical native dependency for React Native's JavaScript runtime on Android, allowing developers to use a modern and optimized JavaScript engine. The project is actively maintained by the React Native community, with releases tied to WebKitGTK updates and React Native compatibility. Recent stable versions like `v294992.0.0` (as of its release) include updates to WebKitGTK and React Native compatibility. Its key differentiator is providing an up-to-date, performant JSC engine for Android, often replacing older system-provided WebView JavaScript engines. This approach allows for more frequent JSC updates on Android, aligning with how React Native on iOS utilizes the built-in, frequently updated JSC.
Common errors
-
Minimum supported Android SDK is 21, but project minSdkVersion is lower.
cause The project's `minSdkVersion` in `build.gradle` is set below 21, which conflicts with `jsc-android` requirements from version `294992.0.0` onwards.fixIncrease `minSdkVersion` to 21 or higher in your `android/app/build.gradle` file. -
Could not find `org.webkit:android-jsc-intl:+` or `org.webkit:android-jsc:+`.
cause This usually indicates that the Maven repository for `jsc-android` is not correctly configured in your `android/build.gradle` or there's a typo in the dependency declaration.fixAdd `maven { url "$rootDir/../node_modules/jsc-android/dist" }` to your `allprojects.repositories` block in `android/build.gradle`. Ensure the dependency in `app/build.gradle` is `implementation "org.webkit:android-jsc-intl:+"`. -
Native crash in JavaScriptCore (JSC) on `ARM64` devices.
cause Older versions of `jsc-android` had known issues leading to crashes on `ARM64` architecture devices.fixUpgrade `jsc-android` to version `250230.2.1` or later, which includes fixes for `arm64` crashes. -
More than one file was found with OS independent path 'lib/armeabi-v7a/libgnustl_shared.so' (or similar native library conflict).
cause Multiple dependencies are trying to include the same native library (`.so` file), leading to an APK packaging conflict during the Android build.fixAdd `packagingOptions { pickFirst '**/libgnustl_shared.so' }` (or the conflicting file path) to your `android` block in `app/build.gradle`.
Warnings
- breaking From `v294992.0.0` onwards, the minimum supported Android SDK version is 21. Projects targeting an SDK version below 21 will fail to build.
- breaking Starting with `v294992.0.0`, only the `Intl` variant (`org.webkit:android-jsc-intl`) is officially supported and distributed. Attempting to use the non-Intl variant or older `android-jsc` artifact might lead to build failures or missing internationalization features.
- gotcha Earlier versions of `jsc-android` (prior to `v250230.2.1`) were known to cause crashes on `arm64` devices due to issues in the underlying WebKitGTK or NDK versions used for compilation.
Install
-
npm install jsc-android -
yarn add jsc-android -
pnpm add jsc-android
Imports
- JavaScriptCore Runtime
import JSC from 'jsc-android';
/* No direct JavaScript/TypeScript import statement for jsc-android. */
Quickstart
import React from 'react';
import { View, Text, StyleSheet, SafeAreaView } from 'react-native';
const App = () => {
return (
<SafeAreaView style={styles.container}>
<View style={styles.content}>
<Text style={styles.title}>Welcome to React Native!</Text>
<Text style={styles.subtitle}>
Your JavaScript code on Android is powered by{' '}
<Text style={styles.highlight}>jsc-android</Text>.
</Text>
<Text style={styles.instruction}>
jsc-android is implicitly included as a native dependency in most React Native projects.
To verify the version used, check your Android project's `app/build.gradle` file for a
dependency similar to `implementation "org.webkit:android-jsc-intl:+"`.
</Text>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5',
},
content: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 10,
color: '#333',
},
subtitle: {
fontSize: 18,
textAlign: 'center',
marginBottom: 20,
color: '#555',
},
highlight: {
fontWeight: 'bold',
color: '#007bff',
},
instruction: {
fontSize: 14,
textAlign: 'center',
color: '#777',
marginTop: 15,
},
});
export default App;