From 71e7cf6ff80ee8a0e7bccc0490c7e8e22e220711 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:09:07 +0200 Subject: [PATCH] Build native Android modules with the project NDK (#7403) * fix(android): align Unistyles NDK version * fix(android): use the project NDK for every native module The diff module still selected the Android Gradle default NDK, causing a second installation after Unistyles was aligned. Inherit the project toolchain and check all configured native projects. --------- Co-authored-by: dwyanewang <908280968@qq.com> Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> --- .../paseo-diff-prototype/android/build.gradle | 1 + .../app/scripts/verify-android-ndk.gradle | 22 +++++++++++++++++++ patches/react-native-unistyles+3.2.4.patch | 12 ++++++++++ 3 files changed, 35 insertions(+) create mode 100644 packages/app/scripts/verify-android-ndk.gradle diff --git a/packages/app/modules/paseo-diff-prototype/android/build.gradle b/packages/app/modules/paseo-diff-prototype/android/build.gradle index f218c03ef8..3f717f4de4 100644 --- a/packages/app/modules/paseo-diff-prototype/android/build.gradle +++ b/packages/app/modules/paseo-diff-prototype/android/build.gradle @@ -12,6 +12,7 @@ useDefaultAndroidSdkVersions() def skiaPackage = new File(["node", "--print", "require.resolve('@shopify/react-native-skia/package.json')"].execute(null, projectDir).text.trim()).parentFile android { + ndkVersion rootProject.ext.ndkVersion namespace "sh.paseo.diffprototype" defaultConfig { externalNativeBuild { diff --git a/packages/app/scripts/verify-android-ndk.gradle b/packages/app/scripts/verify-android-ndk.gradle new file mode 100644 index 0000000000..a53a5406bb --- /dev/null +++ b/packages/app/scripts/verify-android-ndk.gradle @@ -0,0 +1,22 @@ +// After Expo prebuild, run from packages/app/android: +// ./gradlew --init-script ../scripts/verify-android-ndk.gradle verifyAndroidNdk +gradle.projectsEvaluated { + rootProject.tasks.register('verifyAndroidNdk') { + doLast { + def expected = rootProject.ext.ndkVersion + def nativeProjects = rootProject.subprojects.findAll { subproject -> + def android = subproject.extensions.findByName('android') + android != null && (android.externalNativeBuild.cmake.path != null || + android.externalNativeBuild.ndkBuild.path != null) + } + assert !nativeProjects.empty : 'No native Android modules found' + println "Project NDK: ${expected}" + def mismatches = nativeProjects.findAll { subproject -> + def actual = subproject.android.ndkVersion + println "${subproject.path} NDK: ${actual}" + actual != expected + } + assert mismatches.empty : "Native Android modules must use project NDK ${expected}: ${mismatches*.path}" + } + } +} diff --git a/patches/react-native-unistyles+3.2.4.patch b/patches/react-native-unistyles+3.2.4.patch index 25324c6218..0195868340 100644 --- a/patches/react-native-unistyles+3.2.4.patch +++ b/patches/react-native-unistyles+3.2.4.patch @@ -317,3 +317,15 @@ index 39e0d9d..a21ba95 100644 this.stylesCache.clear() this.dependenciesMap.clear() this.disposeListenersMap.clear() +diff --git a/node_modules/react-native-unistyles/android/build.gradle b/node_modules/react-native-unistyles/android/build.gradle +index 195954b..c4ac28c 100644 +--- a/node_modules/react-native-unistyles/android/build.gradle ++++ b/node_modules/react-native-unistyles/android/build.gradle +@@ -38,6 +38,7 @@ if (isNewArchitectureEnabled()) { + + android { + compileSdkVersion safeExtGet('compileSdkVersion', 35) ++ ndkVersion safeExtGet('ndkVersion', '27.1.12297006') + namespace "com.unistyles" + + defaultConfig {