Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNA problems #1277

Closed
Maivand opened this issue Feb 20, 2023 · 16 comments
Closed

JNA problems #1277

Maivand opened this issue Feb 20, 2023 · 16 comments

Comments

@Maivand
Copy link

Maivand commented Feb 20, 2023

I get this error directly after downloading the code trying to demo it.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.vosk.demo, PID: 29261
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-x86/libjnidispatch.so) not found in resource path (.)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:962)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:922)
at com.sun.jna.Native.(Native.java:190)
at com.sun.jna.Native.register(Native.java:1641)
at org.vosk.LibVosk.(LibVosk.java:16)
at org.vosk.LibVosk.setLogLevel(LibVosk.java:70)
at org.vosk.demo.VoskActivity.onCreate(VoskActivity.java:72)
at android.app.Activity.performCreate(Activity.java:7994)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@nshmyrev
Copy link
Collaborator

Please add jna to dependencies

implementation 'net.java.dev.jna:jna:5.8.0@aar'

reverting this change:

alphacep/vosk-android-demo@a4febb2

@nshmyrev
Copy link
Collaborator

This should be fixed in alphacep/vosk-android-demo@443b293

@xekl
Copy link

xekl commented Mar 15, 2023

Thanks, that was fast! Unfortunately, it did not fix everything for me, I now cannot build instead due to a "duplicate class".

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.sun.jna.AltCallingConvention found in modules jetified-jna-5.13.0 (net.java.dev.jna:jna:5.13.0) and jetified-jna-5.13.0-runtime (net.java.dev.jna:jna:5.13.0)
     Duplicate class com.sun.jna.Callback found in modules jetified-jna-5.13.0 (net.java.dev.jna:jna:5.13.0) and jetified-jna-5.13.0-runtime (net.java.dev.jna:jna:5.13.0)
     Duplicate class com.sun.jna.Callback$UncaughtExceptionHandler found in modules jetified-jna-5.13.0 (net.java.dev.jna:jna:5.13.0) and jetified-jna-5.13.0-runtime (net.java.dev.jna:jna:5.13.0)
     .... (and many more)

The same happens when using 5.8.0, as suggested in #1277 (thanks for the link, though, I was thinking I had seen this somewhere before!).

@nshmyrev
Copy link
Collaborator

Ok, I need to investigate more I suppose

@xekl
Copy link

xekl commented Mar 15, 2023

Thank you for looking into this! The suggestions I find online mostly consist of using gradle's "exclude group" feature

{
    exclude group: "net.java.dev.jna", module: "jna"
}

but this does not seem to work for implementation project(':models') whose LibVosk model apparently uses the "duplicate" JNA.

@nshmyrev
Copy link
Collaborator

check contents of apk file, does it include jna libraries?

@xekl
Copy link

xekl commented Mar 15, 2023

According to Android Studio's APK viewer, yes, I think so:

grafik

@nshmyrev
Copy link
Collaborator

Thats strange, it seems to include some unrelated architectures, it should have armv7 instead, not darwin. How come so?

@nshmyrev
Copy link
Collaborator

@xekl
Copy link

xekl commented Mar 15, 2023

Thats strange, it seems to include some unrelated architectures, it should have armv7 instead, not darwin. How come so?

I don't know and I don't know how to find out. Maybe it has something to do with me working on a Mac? Something under the hood that gradle just "manages" without asking?

@nshmyrev
Copy link
Collaborator

@xekl I've just released 0.3.47 and pushed a dependency update here. Could you please update and check?

@xekl
Copy link

xekl commented Mar 16, 2023

Yes, it works now with the new version. Awesome, thanks for the troubleshooting!

@nshmyrev
Copy link
Collaborator

Ok, good

@Maivand
Copy link
Author

Maivand commented Mar 16, 2023 via email

@zooyf
Copy link

zooyf commented Apr 17, 2024

0.3.47

Where is the 0.3.47 version? Neither in release nor in tags...

@nshmyrev
Copy link
Collaborator

@zooyf in maven

https://repo1.maven.org/maven2/com/alphacephei/vosk-android/0.3.47/

it will not help you likely if your problem about M1, I wrote you already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants