From 5840bba5dadd227cdca7a43822ae64803ca5ab92 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sun, 13 Sep 2026 15:26:36 +0200 Subject: [PATCH] build(android): link libdocument_detector against shared libc++ The napi runtime (@nativescript/android-quickjs-ng) already ships libc++_shared.so for every ABI, so the static STL inside libdocument_detector.so was a duplicate. Switch ANDROID_STL to c++_shared. Stripped .so per ABI: arm64-v8a 7132720 -> 6695728 (-427 KB) armeabi-v7a 4503864 -> 4247608 (-250 KB) x86 8374820 -> 7955876 (-409 KB) x86_64 9591536 -> 9174512 (-407 KB) The existing pickFirst rules in App_Resources/*/Android/app.gradle keep a single copy in the APK. Also align src-native ndkVersion with the one the real build uses. Co-Authored-By: Claude Opus 5 --- plugin-nativeprocessor/platforms/android/include.gradle | 4 +++- .../src-native/android/nativeprocessor/build.gradle | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugin-nativeprocessor/platforms/android/include.gradle b/plugin-nativeprocessor/platforms/android/include.gradle index c679f404..f3a4c079 100644 --- a/plugin-nativeprocessor/platforms/android/include.gradle +++ b/plugin-nativeprocessor/platforms/android/include.gradle @@ -8,7 +8,9 @@ android { cmake { cppFlags "-frtti -fexceptions" abiFilters 'armeabi-v7a', "arm64-v8a", 'x86', 'x86_64' - def cmakeArguments = ["-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static"] + // c++_shared: the NativeScript napi runtime already ships libc++_shared.so + // for every ABI, so a static STL would only duplicate it (~0.3MB per ABI) + def cmakeArguments = ["-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared"] if (project.hasProperty("withQRCode")) { cmakeArguments << "-DWITH_QRCODE=1" } diff --git a/plugin-nativeprocessor/src-native/android/nativeprocessor/build.gradle b/plugin-nativeprocessor/src-native/android/nativeprocessor/build.gradle index 0eb44251..aa62dfea 100755 --- a/plugin-nativeprocessor/src-native/android/nativeprocessor/build.gradle +++ b/plugin-nativeprocessor/src-native/android/nativeprocessor/build.gradle @@ -13,7 +13,7 @@ android { cmake { cppFlags "-frtti -fexceptions" abiFilters 'armeabi-v7a', "arm64-v8a", 'x86_64' - arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DWITH_QRCODE=1" + arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared", "-DWITH_QRCODE=1" } } } @@ -24,7 +24,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - ndkVersion "26.3.11579264" + ndkVersion "27.3.13750724" externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt"