I am currently developing a voice assisted flutter app using vosk
and the vosk-flutter-plugin
linked below.
https://github.com/alphacep/vosk-flutter
The app works completely fine in debug mode
but crashes upon opening the view that accesses the vosk-plugin
. It doesn't crash on startup, it crashes only on that specific view. Specifically it crashes when the vosk-flutter-plugin
tries to initialize the vosk
language model, that is loaded from a downloaded zip file.
The console displays the following error:
E/AndroidRuntime(24895): FATAL EXCEPTION: pool-2-thread-1
E/AndroidRuntime(24895): Process: com.example.app, PID: 24895
E/AndroidRuntime(24895): java.lang.UnsatisfiedLinkError: Can't obtain peer field ID for class com.sun.jna.Pointer
E/AndroidRuntime(24895): at com.sun.jna.Native.initIDs(Native Method)
E/AndroidRuntime(24895): at com.sun.jna.Native.<clinit>(Unknown Source:287)
E/AndroidRuntime(24895): at com.sun.jna.Native.H(Unknown Source:0)
E/AndroidRuntime(24895): at org.vosk.LibVosk.<clinit>(Unknown Source:4)
E/AndroidRuntime(24895): at org.vosk.Model.<init>(Unknown Source:0)
E/AndroidRuntime(24895): at u1.b$d.a(Unknown Source:4)
E/AndroidRuntime(24895): at u1.b$d.call(Unknown Source:0)
E/AndroidRuntime(24895): at u1.c$b.run(Unknown Source:2)
E/AndroidRuntime(24895): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/AndroidRuntime(24895): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/AndroidRuntime(24895): at java.lang.Thread.run(Thread.java:1012)
My guess is that it is caused by the flutter code obscuration in the release mode somehow.
Using the --no-shrink
command when building the apk
doesn't work though.
(Also that flag doesn't exist in the flutter build appbundle
command)
It's hard to answer when I don't see any code. But this happened to me and it was related to the expanded widget (I used it in stack widget), and when I refactor the code, it did not crash in the release mode.