From 65dc3fece67c70dead38532cb27df49ff4db9ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yongmin=20Yoo=20=EC=9C=A0=EC=9A=A9=EB=AF=BC?= Date: Tue, 30 Jun 2026 19:12:04 +0900 Subject: [PATCH] examples : Improved inference performance of Android example project (#3913) * fix/android-debug-inference-issue: Applied BUILD_TYPE=Release to NDK build of whisper.android example * fix/android-debug-inference-issue: Applied BUILD_TYPE=Release to NDK build of whisper.android.java example --- examples/whisper.android.java/app/build.gradle | 12 ++++++++++++ examples/whisper.android/app/build.gradle | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/examples/whisper.android.java/app/build.gradle b/examples/whisper.android.java/app/build.gradle index 543701e1b..2dcda0944 100644 --- a/examples/whisper.android.java/app/build.gradle +++ b/examples/whisper.android.java/app/build.gradle @@ -25,6 +25,18 @@ android { } buildTypes { + debug { + externalNativeBuild { + cmake { + // When the AGP build type is Debug, the native (NDK/CMake) build does not run + // compiler optimizations by default, causing a critical performance issue. + // We force CMAKE_BUILD_TYPE to Release here so native code stays optimized + // even in Debug AGP builds. + arguments "-DCMAKE_BUILD_TYPE=Release" + } + } + } + release { signingConfig signingConfigs.debug minifyEnabled true diff --git a/examples/whisper.android/app/build.gradle b/examples/whisper.android/app/build.gradle index 9f407998c..9ed13f845 100644 --- a/examples/whisper.android/app/build.gradle +++ b/examples/whisper.android/app/build.gradle @@ -22,12 +22,25 @@ android { } buildTypes { + debug { + externalNativeBuild { + cmake { + // When the AGP build type is Debug, the native (NDK/CMake) build does not run + // compiler optimizations by default, causing a critical performance issue. + // We force CMAKE_BUILD_TYPE to Release here so native code stays optimized + // even in Debug AGP builds. + arguments "-DCMAKE_BUILD_TYPE=Release" + } + } + } + release { signingConfig signingConfigs.debug minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17