Skip to content

fix(voice): keep sherpa-onnx classes from R8 so on-device STT loads in release (6.8.13)#29

Merged
leinss merged 2 commits into
mainfrom
feature/sherpa-keep
Jul 14, 2026
Merged

fix(voice): keep sherpa-onnx classes from R8 so on-device STT loads in release (6.8.13)#29
leinss merged 2 commits into
mainfrom
feature/sherpa-keep

Conversation

@leinss

@leinss leinss commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Root cause

On-device voice input never ran in any minified release build (Play/F-Droid/APK). libsherpa-onnx-jni.so reads config fields by name via JNI GetFieldID (e.g. decodingMethod on OfflineRecognizerConfig), but R8 renamed those fields/classes, so OfflineRecognizer construction threw java.lang.RuntimeException: Failed to get field ID for decodingMethod. Unminified debug builds + instrumented tests kept the names, so it passed in dev and hid the bug.

Confirmed on-device via the in-app log (6.8.12's single-line exception logging surfaced it) and against the release R8 mapping (OfflineSenseVoiceModelConfig -> n5.p, fields -> a/b/c).

Fix

-keep class com.k2fsa.sherpa.onnx.** { *; } in proguard-rules.pro.

Verification

  • Built minified release; R8 mapping now shows all 104 sherpa classes map to identity names (0 obfuscated), and OfflineRecognizerConfig has no field renames — so JNI GetFieldID resolves.
  • Device (Play internal): on-device dictation → speak → accept → inserts text.

leinss added 2 commits July 14, 2026 23:44
…n release

libsherpa-onnx-jni.so reads config fields by name via JNI GetFieldID (e.g.
"decodingMethod" on OfflineRecognizerConfig). R8 renamed those fields/classes in
minified release builds, so the native OfflineRecognizer failed to construct with
"java.lang.RuntimeException: Failed to get field ID for decodingMethod" — on-device
voice input never ran in any released build (Play/F-Droid/APK), while unminified
debug builds and instrumented tests worked, hiding it.

Add `-keep class com.k2fsa.sherpa.onnx.** { *; }`. Verified against the release R8
mapping: all 104 sherpa classes now map to identity names (was obfuscating classes
and fields), so JNI name lookups resolve.
@leinss
leinss merged commit 9c87a95 into main Jul 14, 2026
@leinss
leinss deleted the feature/sherpa-keep branch July 14, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant