alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.37k stars 1.04k forks source link

Android Crash on release mode #1458

Open sGeeK44 opened 8 months ago

sGeeK44 commented 8 months ago

When android app is build with def enableProguardInReleaseBuilds = true, application crash on LibVosk initialiation with that error:

11-04 15:22:30.599 10918 11365 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Can't obtain peer field ID for class com.sun.jna.Pointer
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at com.sun.jna.Native.initIDs(Native Method)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at com.sun.jna.Native.<clinit>(Unknown Source:333)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at org.vosk.LibVosk.<clinit>(Unknown Source:4)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at org.vosk.Model.<init>(Unknown Source:0)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at z7.k.i(Unknown Source:6)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at z7.k.b(Unknown Source:0)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at z7.h.run(Unknown Source:12)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
11-04 15:22:30.599 10918 11365 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:1012)

To fix it need to add rule -keep class com.sun.jna.** { *; } in proguard-rules.pro file.

sGeeK44 commented 8 months ago

Maybe when can add this tips in android/Readme.md ? I speet severals hours to find reason and associated fix. I can be helpful for other users.

nshmyrev commented 8 months ago

Sure, please submit a patch