From 5be6a93ff55cf94af89e911e7095c02ee85488f9 Mon Sep 17 00:00:00 2001 From: ashb155 Date: Sun, 22 Nov 2026 20:33:48 +0530 Subject: [PATCH 1/8] preserve native dictionary classes from R8 minification + fallback signing config for release --- CHANGELOG.md | 4 ++++ app/build.gradle.kts | 7 ++++++- app/proguard-rules.pro | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c2e967ee..02dff0d5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). ## [Upcoming] Scribe-Android v1.X.Y +### 🐛 Bug Fixes + +- ProGuard keep rules were added for JNI-bound classes and methods, preventing crashes in release builds ([#796](https://github.com/scribe-org/Scribe-Android/issues/796)). + ## Scribe-Android v1.0.0 ### MVP release of Scribe - Language Keyboards on Android diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 804367b47..00c3aa44f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -135,7 +135,12 @@ android { getByName("release") { isMinifyEnabled = true proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") - signingConfig = signingConfigs.getByName("release") + signingConfig = + if (keystorePropertiesFile.exists()) { + signingConfigs.getByName("release") + } else { + signingConfigs.getByName("debug") + } } } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index e69de29bb..523e07311 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +-keepclasseswithmembernames class * { + native ; +} + +-keep class be.scri.inputmethod.keyboard.** { *; } +-keep class be.scri.inputmethod.latin.** { *; } +-keep class be.scri.latin.** { *; } From 52fab7dd676bcccf2065d003136df04ce8ac3917 Mon Sep 17 00:00:00 2001 From: ashb155 Date: Sun, 22 Nov 2026 23:50:54 +0530 Subject: [PATCH 2/8] native fallbacks --- CHANGELOG.md | 3 +- .../be/scri/helpers/NativeSuggestionEngine.kt | 47 ++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea4df1c49..1cd86f340 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). ### 🐛 Bug Fixes -- ProGuard keep rules were added for JNI-bound classes and methods, preventing crashes in release builds ([#796](https://github.com/scribe-org/Scribe-Android/issues/796)). +- ProGuard keep rules and defensive fallbacks in NativeSuggestionEngine were added for JNI-bound classes and methods, preventing crashes in release builds ([#796](https://github.com/scribe-org/Scribe-Android/issues/796)). + ### 🔒 Security - The unused `WRITE_EXTERNAL_STORAGE` permission was removed so the app requests only network access ([#791](https://github.com/scribe-org/Scribe-Android/issues/791)). diff --git a/app/src/main/java/be/scri/helpers/NativeSuggestionEngine.kt b/app/src/main/java/be/scri/helpers/NativeSuggestionEngine.kt index 292ee1df8..8bd026066 100644 --- a/app/src/main/java/be/scri/helpers/NativeSuggestionEngine.kt +++ b/app/src/main/java/be/scri/helpers/NativeSuggestionEngine.kt @@ -12,6 +12,7 @@ import be.scri.latin.NgramContext import be.scri.latin.common.ComposedData import be.scri.latin.dictionary.ReadOnlyBinaryDictionary import be.scri.latin.settings.SettingsValuesForSuggestion +import be.scri.latin.utils.JniUtils import java.io.File import java.io.FileOutputStream import java.io.IOException @@ -30,7 +31,21 @@ class NativeSuggestionEngine(private val context: Context) { } private val loadedDicts = HashMap() - private val dummyProximityInfo = ProximityInfo() + + /** + * Checks whether the underlying native library (libjni_latinime.so) was loaded successfully. + */ + val isNativeAvailable: Boolean + get() = JniUtils.sHaveGestureLib + + private val dummyProximityInfo by lazy { + try { + if (isNativeAvailable) ProximityInfo() else null + } catch (t: Throwable) { + Log.e(TAG, "Failed to initialize dummy ProximityInfo", t) + null + } + } /** * Map a language string to its corresponding main dictionary asset name and Locale. @@ -108,6 +123,8 @@ class NativeSuggestionEngine(private val context: Context) { */ @Synchronized fun getDictionary(language: String): ReadOnlyBinaryDictionary? { + if (!isNativeAvailable) return null + val cacheKey = language.lowercase(Locale.ROOT) loadedDicts[cacheKey]?.let { return it } @@ -132,8 +149,8 @@ class NativeSuggestionEngine(private val context: Context) { dict.close() null } - } catch (e: Exception) { - Log.e(TAG, "Error initializing ReadOnlyBinaryDictionary for $language", e) + } catch (t: Throwable) { + Log.e(TAG, "Error initializing ReadOnlyBinaryDictionary for $language", t) null } } @@ -148,8 +165,9 @@ class NativeSuggestionEngine(private val context: Context) { limit: Int = 3, profanity: Set = emptySet() ): List { + if (!isNativeAvailable || prefix.isBlank()) return emptyList() + val proximityInfo = dummyProximityInfo ?: return emptyList() val dict = getDictionary(language) ?: return emptyList() - if (prefix.isBlank()) return emptyList() return try { val composedData = ComposedData.createForWord(prefix) @@ -162,7 +180,7 @@ class NativeSuggestionEngine(private val context: Context) { val suggestions = dict.getSuggestions( composedData, ngramContext, - dummyProximityInfo.nativeProximityInfo, // proximityInfoHandle + proximityInfo.nativeProximityInfo, // proximityInfoHandle SettingsValuesForSuggestion(true, false), // blockPotentiallyOffensive, spaceAwareGesture 1, // sessionId 1.0f, // weightForLocale @@ -180,8 +198,8 @@ class NativeSuggestionEngine(private val context: Context) { ?.map { if (isCapitalized) it.replaceFirstChar { c -> c.uppercaseChar() } else it } ?.take(limit) ?: emptyList() - } catch (e: Exception) { - Log.e(TAG, "Error fetching native suggestions for $prefix", e) + } catch (t: Throwable) { + Log.e(TAG, "Error fetching native suggestions for $prefix", t) emptyList() } } @@ -195,8 +213,9 @@ class NativeSuggestionEngine(private val context: Context) { limit: Int = 3, profanity: Set = emptySet() ): List { + if (!isNativeAvailable || lastWord.isNullOrBlank()) return emptyList() + val proximityInfo = dummyProximityInfo ?: return emptyList() val dict = getDictionary(language) ?: return emptyList() - if (lastWord.isNullOrBlank()) return emptyList() return try { val wordInfo = NgramContext.WordInfo(lastWord) @@ -205,7 +224,7 @@ class NativeSuggestionEngine(private val context: Context) { val suggestions = dict.getSuggestions( composedData, ngramContext, - dummyProximityInfo.nativeProximityInfo, // proximityInfoHandle + proximityInfo.nativeProximityInfo, // proximityInfoHandle SettingsValuesForSuggestion(true, false), // blockPotentiallyOffensive, spaceAwareGesture 1, // sessionId 1.0f, // weightForLocale @@ -220,8 +239,8 @@ class NativeSuggestionEngine(private val context: Context) { } ?.take(limit) ?: emptyList() - } catch (e: Exception) { - Log.e(TAG, "Error fetching native next-word suggestions for $lastWord", e) + } catch (t: Throwable) { + Log.e(TAG, "Error fetching native next-word suggestions for $lastWord", t) emptyList() } } @@ -232,7 +251,11 @@ class NativeSuggestionEngine(private val context: Context) { @Synchronized fun close() { for (dict in loadedDicts.values) { - dict.close() + try { + dict.close() + } catch (t: Throwable) { + Log.e(TAG, "Error closing dictionary", t) + } } loadedDicts.clear() } From 29bca0fb41660482a316f866750eaf9dd3a1cb07 Mon Sep 17 00:00:00 2001 From: ashb155 Date: Mon, 23 Nov 2026 01:39:55 +0530 Subject: [PATCH 3/8] add release build smoke test workflow --- .github/workflows/ci_android.yaml | 47 ++++++++++++++++ CHANGELOG.md | 4 ++ scripts/smoke_test_release.sh | 91 +++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100755 scripts/smoke_test_release.sh diff --git a/.github/workflows/ci_android.yaml b/.github/workflows/ci_android.yaml index 3fff29f02..3cfc3c5fd 100644 --- a/.github/workflows/ci_android.yaml +++ b/.github/workflows/ci_android.yaml @@ -12,6 +12,7 @@ on: - "**/*.kts" - "**/*.xml" - "app/src/**" + - "scripts/**" - ".github/workflows/ci_android.yaml" push: branches: @@ -21,6 +22,7 @@ on: - "**/*.kts" - "**/*.xml" - "app/src/**" + - "scripts/**" - ".github/workflows/ci_android.yaml" permissions: @@ -96,6 +98,9 @@ jobs: - name: Build App run: ./gradlew assembleDebug + - name: Verify R8 Minification on Release + run: ./gradlew minifyKeyboardsReleaseWithR8 minifyConjugateReleaseWithR8 + - name: Upload Debug APK uses: actions/upload-artifact@v4 if: success() @@ -146,3 +151,45 @@ jobs: adb wait-for-device adb shell input keyevent 82 ./gradlew connected${{ matrix.flavor }}DebugAndroidTest --stacktrace + + release_smoke_test: + runs-on: ubuntu-latest + strategy: + matrix: + flavor: [Keyboards, Conjugate] + fail-fast: false + name: Run Release Smoke Test (${{ matrix.flavor }}) + timeout-minutes: 35 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Prepare App + uses: ./.github/composite/prepareApp + + - name: Enable KVM Group Permissions + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Pre-build Release APKs + run: ./gradlew assemble${{ matrix.flavor }}Release + + - name: Run Release Smoke Test on Emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: google_apis + arch: x86_64 + profile: Nexus 6 + ram-size: 2048M + heap-size: 512M + disk-size: 6000M + emulator-options: "-no-window -no-audio -no-boot-anim -camera-back none -camera-front none -gpu swiftshader_indirect -no-snapshot -wipe-data -accel on" + disable-animations: true + force-avd-creation: false + script: bash scripts/smoke_test_release.sh ${{ matrix.flavor }} + diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd86f340..f495835b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). - The unused `androidx.biometric` and `androidx.documentfile` dependencies were removed ([#791](https://github.com/scribe-org/Scribe-Android/issues/791)). +### ✅ Tests + +- A CI release smoke test workflow and R8 minification verification were added to test release builds on emulators and prevent crash regressions ([#799](https://github.com/scribe-org/Scribe-Android/issues/799)). + ## Scribe-Android v1.0.0 ### MVP release of Scribe - Language Keyboards on Android diff --git a/scripts/smoke_test_release.sh b/scripts/smoke_test_release.sh new file mode 100755 index 000000000..f52008282 --- /dev/null +++ b/scripts/smoke_test_release.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later + +set -euo pipefail + +FLAVOR="${1:-Keyboards}" + +echo "==================================================" +echo "Starting Release Smoke Test for flavor: $FLAVOR" +echo "==================================================" + +# Wait for device/emulator to boot +echo "Waiting for device to finish booting..." +adb wait-for-device +while [[ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" != "1" ]]; do + echo "Device not ready yet, sleeping 2s..." + sleep 2 +done +echo "Device boot completed." + +# Wake screen and dismiss lockscreen +adb shell input keyevent 82 || true +sleep 1 + +# Clear logcat buffer to only capture fresh logs +adb logcat -c + +if [[ "$FLAVOR" == "Keyboards" ]]; then + PACKAGE="be.scri.keyboards" + ACTIVITY="be.scri.activities.MainActivity" + IME_SERVICE="be.scri.keyboards/be.scri.services.EnglishKeyboardIME" + + echo "Installing Scribe Keyboards Release APK..." + ./gradlew installKeyboardsRelease + + echo "Enabling Scribe keyboard IME: $IME_SERVICE" + adb shell ime enable "$IME_SERVICE" + + echo "Setting Scribe keyboard as default IME..." + adb shell ime set "$IME_SERVICE" + + echo "Active IMEs on system:" + adb shell ime list -s + + echo "Launching Scribe Keyboards MainActivity..." + adb shell am start -W -n "$PACKAGE/$ACTIVITY" + sleep 4 + + echo "Focusing practice text field to activate keyboard..." + adb shell input tap 500 800 || true + sleep 2 + + echo "Simulating text input to trigger keyboard suggestion engine..." + adb shell input text "hello" || true + sleep 3 + +elif [[ "$FLAVOR" == "Conjugate" ]]; then + PACKAGE="be.scri.conjugate" + ACTIVITY="be.scri.activities.MainActivity" + + echo "Installing Scribe Conjugate Release APK..." + ./gradlew installConjugateRelease + + echo "Launching Scribe Conjugate MainActivity..." + adb shell am start -W -n "$PACKAGE/$ACTIVITY" + sleep 4 + +else + echo "Unknown flavor '$FLAVOR'. Must be 'Keyboards' or 'Conjugate'." + exit 1 +fi + +echo "Verifying process '$PACKAGE' is alive..." +PID=$(adb shell "pidof $PACKAGE 2>/dev/null || ps -A | grep $PACKAGE | awk '{print \$2}'" | tr -d '\r') +if [[ -z "$PID" ]]; then + echo "ERROR: Process '$PACKAGE' is not running (crashed on startup)!" + echo "Recent logcat dump:" + adb logcat -d | tail -n 120 + exit 1 +fi +echo "Process '$PACKAGE' is running (PID: $PID)" + +echo "Checking logcat for crashes, unsatisfied link errors, or ANRs..." +if adb logcat -d | grep -E "(FATAL EXCEPTION|UnsatisfiedLinkError|ANR in $PACKAGE)"; then + echo "ERROR: Critical crash, Linkage error, or ANR detected in release build!" + exit 1 +fi + +echo "==================================================" +echo "Release Smoke Test for $FLAVOR PASSED!" +echo "==================================================" From d664978c511746c1350e036fe51720110802d003 Mon Sep 17 00:00:00 2001 From: ashb155 Date: Mon, 23 Nov 2026 22:48:13 +0530 Subject: [PATCH 4/8] revert release and add minifiedDebug build type --- app/build.gradle.kts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 650622739..dc5ef1259 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -132,15 +132,17 @@ android { enableUnitTestCoverage = true enableAndroidTestCoverage = true } + create("minifiedDebug") { + initWith(getByName("debug")) + isDebuggable = false + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + matchingFallbacks += listOf("debug") + } getByName("release") { isMinifyEnabled = true proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") - signingConfig = - if (keystorePropertiesFile.exists()) { - signingConfigs.getByName("release") - } else { - signingConfigs.getByName("debug") - } + signingConfig = signingConfigs.getByName("release") } } From 7f82454733868f97f2340565d913d40dbca83d0b Mon Sep 17 00:00:00 2001 From: ashb155 Date: Mon, 23 Nov 2026 23:08:06 +0530 Subject: [PATCH 5/8] update smoke test workflow and script to use minifiedDebug --- .github/workflows/ci_android.yaml | 8 ++++---- CHANGELOG.md | 2 +- scripts/smoke_test_release.sh | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci_android.yaml b/.github/workflows/ci_android.yaml index 3cfc3c5fd..5cc33ba75 100644 --- a/.github/workflows/ci_android.yaml +++ b/.github/workflows/ci_android.yaml @@ -98,8 +98,8 @@ jobs: - name: Build App run: ./gradlew assembleDebug - - name: Verify R8 Minification on Release - run: ./gradlew minifyKeyboardsReleaseWithR8 minifyConjugateReleaseWithR8 + - name: Verify R8 Minification + run: ./gradlew minifyKeyboardsMinifiedDebugWithR8 minifyConjugateMinifiedDebugWithR8 - name: Upload Debug APK uses: actions/upload-artifact@v4 @@ -175,8 +175,8 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - - name: Pre-build Release APKs - run: ./gradlew assemble${{ matrix.flavor }}Release + - name: Pre-build Minified APKs + run: ./gradlew assemble${{ matrix.flavor }}MinifiedDebug - name: Run Release Smoke Test on Emulator uses: reactivecircus/android-emulator-runner@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index f495835b4..c1d23e4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). ### ✅ Tests -- A CI release smoke test workflow and R8 minification verification were added to test release builds on emulators and prevent crash regressions ([#799](https://github.com/scribe-org/Scribe-Android/issues/799)). +- A CI smoke test workflow and R8 minification verification were added to test minified builds on emulators and prevent crash regressions ([#799](https://github.com/scribe-org/Scribe-Android/issues/799)). ## Scribe-Android v1.0.0 diff --git a/scripts/smoke_test_release.sh b/scripts/smoke_test_release.sh index f52008282..54085599c 100755 --- a/scripts/smoke_test_release.sh +++ b/scripts/smoke_test_release.sh @@ -26,12 +26,12 @@ sleep 1 adb logcat -c if [[ "$FLAVOR" == "Keyboards" ]]; then - PACKAGE="be.scri.keyboards" + PACKAGE="be.scri.keyboards.debug" ACTIVITY="be.scri.activities.MainActivity" - IME_SERVICE="be.scri.keyboards/be.scri.services.EnglishKeyboardIME" + IME_SERVICE="be.scri.keyboards.debug/be.scri.services.EnglishKeyboardIME" - echo "Installing Scribe Keyboards Release APK..." - ./gradlew installKeyboardsRelease + echo "Installing Scribe Keyboards Minified APK..." + ./gradlew installKeyboardsMinifiedDebug echo "Enabling Scribe keyboard IME: $IME_SERVICE" adb shell ime enable "$IME_SERVICE" @@ -55,11 +55,11 @@ if [[ "$FLAVOR" == "Keyboards" ]]; then sleep 3 elif [[ "$FLAVOR" == "Conjugate" ]]; then - PACKAGE="be.scri.conjugate" + PACKAGE="be.scri.conjugate.debug" ACTIVITY="be.scri.activities.MainActivity" - echo "Installing Scribe Conjugate Release APK..." - ./gradlew installConjugateRelease + echo "Installing Scribe Conjugate Minified APK..." + ./gradlew installConjugateMinifiedDebug echo "Launching Scribe Conjugate MainActivity..." adb shell am start -W -n "$PACKAGE/$ACTIVITY" From 9de02af1f4f97605f1bc4f17a19db03f3cc95401 Mon Sep 17 00:00:00 2001 From: ashb155 Date: Tue, 24 Nov 2026 00:53:23 +0530 Subject: [PATCH 6/8] smoke test + CI fixes --- .github/workflows/ci_android.yaml | 2 ++ scripts/smoke_test_release.sh | 49 +++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci_android.yaml b/.github/workflows/ci_android.yaml index 5cc33ba75..887a6fd35 100644 --- a/.github/workflows/ci_android.yaml +++ b/.github/workflows/ci_android.yaml @@ -11,6 +11,7 @@ on: - "**/*.kt" - "**/*.kts" - "**/*.xml" + - "**/*.pro" - "app/src/**" - "scripts/**" - ".github/workflows/ci_android.yaml" @@ -21,6 +22,7 @@ on: - "**/*.kt" - "**/*.kts" - "**/*.xml" + - "**/*.pro" - "app/src/**" - "scripts/**" - ".github/workflows/ci_android.yaml" diff --git a/scripts/smoke_test_release.sh b/scripts/smoke_test_release.sh index 54085599c..227467345 100755 --- a/scripts/smoke_test_release.sh +++ b/scripts/smoke_test_release.sh @@ -44,15 +44,40 @@ if [[ "$FLAVOR" == "Keyboards" ]]; then echo "Launching Scribe Keyboards MainActivity..." adb shell am start -W -n "$PACKAGE/$ACTIVITY" - sleep 4 + sleep 3 + + echo "Opening text input to display active keyboard IME..." + adb shell am start -a android.intent.action.SENDTO -d "sms:5551234" || true + sleep 3 + + SCREEN_SIZE=$(adb shell wm size | awk '{print $NF}' | tr -d '\r') + WIDTH=$(echo "$SCREEN_SIZE" | cut -d'x' -f1) + HEIGHT=$(echo "$SCREEN_SIZE" | cut -d'x' -f2) - echo "Focusing practice text field to activate keyboard..." - adb shell input tap 500 800 || true + # Tap input field + INPUT_X=$(( WIDTH / 2 )) + INPUT_Y=$(( HEIGHT * 90 / 100 )) + echo "Focusing input field at ($INPUT_X, $INPUT_Y)..." + adb shell input tap "$INPUT_X" "$INPUT_Y" || true sleep 2 - echo "Simulating text input to trigger keyboard suggestion engine..." - adb shell input text "hello" || true - sleep 3 + # Check whether the keyboard IME is shown + if adb shell dumpsys input_method | grep -q "mInputShown=true"; then + echo "Keyboard IME is visible on screen (mInputShown=true)." + else + echo "Retrying focus tap on input field..." + adb shell input tap "$INPUT_X" "$INPUT_Y" || true + sleep 2 + fi + + # Tap keyboard keys in the center of the soft keyboard to trigger the JNI suggestion engine + KEY_X=$(( WIDTH / 2 )) + KEY_Y=$(( HEIGHT * 70 / 100 )) + echo "Tapping keyboard keys at ($KEY_X, $KEY_Y) to trigger native suggestion engine..." + adb shell input tap "$KEY_X" "$KEY_Y" || true + sleep 1 + adb shell input tap "$KEY_X" "$KEY_Y" || true + sleep 2 elif [[ "$FLAVOR" == "Conjugate" ]]; then PACKAGE="be.scri.conjugate.debug" @@ -80,9 +105,15 @@ if [[ -z "$PID" ]]; then fi echo "Process '$PACKAGE' is running (PID: $PID)" -echo "Checking logcat for crashes, unsatisfied link errors, or ANRs..." -if adb logcat -d | grep -E "(FATAL EXCEPTION|UnsatisfiedLinkError|ANR in $PACKAGE)"; then - echo "ERROR: Critical crash, Linkage error, or ANR detected in release build!" +echo "Checking logcat for crashes or unsatisfied link errors in $PACKAGE..." + +if adb logcat -d --pid="$PID" | grep -E "(FATAL EXCEPTION|UnsatisfiedLinkError|NoSuchMethodError|AndroidRuntime)"; then + echo "ERROR: Critical crash or Linkage error detected in $PACKAGE!" + exit 1 +fi + +if adb logcat -d | grep -E "(Process: $PACKAGE.*FATAL EXCEPTION|ANR in $PACKAGE)"; then + echo "ERROR: Process crash or ANR detected in $PACKAGE!" exit 1 fi From fb04870895cdba16dfd5e703597c907c23a3aaee Mon Sep 17 00:00:00 2001 From: ashb155 Date: Tue, 24 Nov 2026 14:47:47 +0530 Subject: [PATCH 7/8] minification on debug build via flag --- app/build.gradle.kts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index dc5ef1259..e7a05cee7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -126,18 +126,18 @@ android { } } + val isMinify = project.findProperty("minify")?.let { it == "" || it.toString().toBoolean() } ?: false + buildTypes { getByName("debug") { applicationIdSuffix = ".debug" enableUnitTestCoverage = true enableAndroidTestCoverage = true - } - create("minifiedDebug") { - initWith(getByName("debug")) - isDebuggable = false - isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") - matchingFallbacks += listOf("debug") + if (isMinify) { + isDebuggable = false + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } } getByName("release") { isMinifyEnabled = true From 85ee5383966c49c6ba12872847a5f47d43ab369a Mon Sep 17 00:00:00 2001 From: ashb155 Date: Tue, 24 Nov 2026 15:49:57 +0530 Subject: [PATCH 8/8] update smoke test workflow and script to use flag --- .github/workflows/ci_android.yaml | 4 ++-- scripts/smoke_test_release.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_android.yaml b/.github/workflows/ci_android.yaml index 887a6fd35..6296f9061 100644 --- a/.github/workflows/ci_android.yaml +++ b/.github/workflows/ci_android.yaml @@ -101,7 +101,7 @@ jobs: run: ./gradlew assembleDebug - name: Verify R8 Minification - run: ./gradlew minifyKeyboardsMinifiedDebugWithR8 minifyConjugateMinifiedDebugWithR8 + run: ./gradlew minifyKeyboardsDebugWithR8 minifyConjugateDebugWithR8 -Pminify - name: Upload Debug APK uses: actions/upload-artifact@v4 @@ -178,7 +178,7 @@ jobs: sudo udevadm trigger --name-match=kvm - name: Pre-build Minified APKs - run: ./gradlew assemble${{ matrix.flavor }}MinifiedDebug + run: ./gradlew assemble${{ matrix.flavor }}Debug -Pminify - name: Run Release Smoke Test on Emulator uses: reactivecircus/android-emulator-runner@v2 diff --git a/scripts/smoke_test_release.sh b/scripts/smoke_test_release.sh index 227467345..ceaef796e 100755 --- a/scripts/smoke_test_release.sh +++ b/scripts/smoke_test_release.sh @@ -31,7 +31,7 @@ if [[ "$FLAVOR" == "Keyboards" ]]; then IME_SERVICE="be.scri.keyboards.debug/be.scri.services.EnglishKeyboardIME" echo "Installing Scribe Keyboards Minified APK..." - ./gradlew installKeyboardsMinifiedDebug + ./gradlew installKeyboardsDebug -Pminify echo "Enabling Scribe keyboard IME: $IME_SERVICE" adb shell ime enable "$IME_SERVICE" @@ -84,7 +84,7 @@ elif [[ "$FLAVOR" == "Conjugate" ]]; then ACTIVITY="be.scri.activities.MainActivity" echo "Installing Scribe Conjugate Minified APK..." - ./gradlew installConjugateMinifiedDebug + ./gradlew installConjugateDebug -Pminify echo "Launching Scribe Conjugate MainActivity..." adb shell am start -W -n "$PACKAGE/$ACTIVITY"