Skip to content

Commit 08eafe2

Browse files
authored
chore: integrate jsc into example on android (#4)
1 parent 0c3d649 commit 08eafe2

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

android/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ target_include_directories(
4848
"${COMMON_DIR}"
4949
"${REACT_NATIVE_DIR}/ReactCommon"
5050
"${REACT_NATIVE_DIR}/ReactCommon/jsiexecutor"
51+
"${REACT_NATIVE_DIR}/ReactCommon/jsitooling"
5152
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni"
5253
)
5354

example/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ def enableProguardInReleaseBuilds = false
6363
* The preferred build flavor of JavaScriptCore (JSC)
6464
*
6565
* For example, to use the international variant, you can use:
66-
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
66+
* `def jscFlavor = 'io.github.react-native-community:jsc-android-intl:2026004.+'`
6767
*
6868
* The international variant includes ICU i18n library and necessary data
6969
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
7070
* give correct results when using with locales other than en-US. Note that
7171
* this variant is about 6MiB larger per architecture than default.
7272
*/
73-
def jscFlavor = 'org.webkit:android-jsc:+'
73+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
7474

7575
android {
7676
ndkVersion rootProject.ext.ndkVersion

example/android/app/src/main/java/com/jscexample/MainApplication.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ import com.facebook.react.ReactApplication
66
import com.facebook.react.ReactHost
77
import com.facebook.react.ReactNativeHost
88
import com.facebook.react.ReactPackage
9+
import com.facebook.react.bridge.JavaScriptExecutorFactory
910
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1011
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1112
import com.facebook.react.defaults.DefaultReactNativeHost
13+
import com.facebook.react.modules.systeminfo.AndroidInfoHelpers
1214
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1315
import com.facebook.soloader.SoLoader
16+
import io.github.reactnativecommunity.javascriptcore.JSCExecutorFactory
17+
import io.github.reactnativecommunity.javascriptcore.JSCRuntimeFactory
1418

1519
class MainApplication : Application(), ReactApplication {
1620

@@ -28,10 +32,13 @@ class MainApplication : Application(), ReactApplication {
2832

2933
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
3034
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
35+
36+
override fun getJavaScriptExecutorFactory(): JavaScriptExecutorFactory =
37+
JSCExecutorFactory(packageName, AndroidInfoHelpers.getFriendlyDeviceName())
3138
}
3239

3340
override val reactHost: ReactHost
34-
get() = getDefaultReactHost(applicationContext, reactNativeHost)
41+
get() = getDefaultReactHost(applicationContext, reactNativeHost, JSCRuntimeFactory())
3542

3643
override fun onCreate() {
3744
super.onCreate()

example/android/gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ newArchEnabled=true
3636

3737
# Use this property to enable or disable the Hermes JS engine.
3838
# If set to false, you will be using JSC instead.
39-
hermesEnabled=true
39+
hermesEnabled=false
40+
41+
useThirdPartyJSC=true

0 commit comments

Comments
 (0)