fix(voice): keep sherpa-onnx classes from R8 so on-device STT loads in release (6.8.13)#29
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
On-device voice input never ran in any minified release build (Play/F-Droid/APK).
libsherpa-onnx-jni.soreads config fields by name via JNIGetFieldID(e.g.decodingMethodonOfflineRecognizerConfig), but R8 renamed those fields/classes, soOfflineRecognizerconstruction threwjava.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.** { *; }inproguard-rules.pro.Verification
OfflineRecognizerConfighas no field renames — so JNIGetFieldIDresolves.