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>
This commit is contained in:
paseo-bot[bot]
2026-10-19 20:09:07 +02:00
committed by GitHub
co-authored by dwyanewang
parent eda3e4318f
commit 71e7cf6ff8
3 changed files with 35 additions and 0 deletions
@@ -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 {
@@ -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}"
}
}
}
@@ -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 {