Open History to see the last commit
1const { withProjectBuildGradle } = require("expo/config-plugins");
2
3// react-native-shiki-engine 0.3.12 asks for `com.facebook.fbjni:fbjni:+`, which Gradle
4// resolves to the newest release on Maven Central. That is now 0.8.x, built
5// with NDK 28, while React Native links the NDK 27.1 C++ runtime and requires
6// 0.7.0. The two disagree on libc++, so the app dies in
7// ReactNativeFeatureFlagsCxxInterop's static initializer before any JavaScript
8// runs ("cannot locate symbol __cxa_init_primary_exception").
9//
10// Keep this equal to `fbjni` in react-native/gradle/libs.versions.toml, and move
11// it with React Native. withAndroidFbjniVersion.test.mjs fails when they differ.
12const FBJNI_VERSION = "0.7.0";
13const MARKER = "withAndroidFbjniVersion";
14
15const BLOCKS = {
16 groovy: `
17// Added by ${MARKER}: keep fbjni on the version React Native ships against.
18allprojects {
19 configurations.all {
20 resolutionStrategy.force 'com.facebook.fbjni:fbjni:${FBJNI_VERSION}'
21 }
22}
23`,
24 kt: `
25// Added by ${MARKER}: keep fbjni on the version React Native ships against.
26allprojects {
27 configurations.all {
28 resolutionStrategy.force("com.facebook.fbjni:fbjni:${FBJNI_VERSION}")
29 }
30}
31`,
32};
33
34module.exports = function withAndroidFbjniVersion(config) {
35 return withProjectBuildGradle(config, (nextConfig) => {
36 const { contents, language } = nextConfig.modResults;
37 const block = BLOCKS[language];
38 if (block === undefined) {
39 throw new Error(`${MARKER}: unsupported root build.gradle language "${language}".`);
40 }
41 if (!contents.includes(MARKER)) {
42 nextConfig.modResults.contents = `${contents.trimEnd()}\n${block}`;
43 }
44 return nextConfig;
45 });
46};