terl / lazysodium-android

An Android implementation of the Libsodium cryptography library. For the lazy dev.
https://github.com/terl/lazysodium-java/wiki
Mozilla Public License 2.0
108 stars 25 forks source link

Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path (.) #60

Open aagam-chai opened 1 year ago

aagam-chai commented 1 year ago

Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path (.)

For the Context

As I was creating an Android library, encryption was necessary, therefore I added lazysodium to it.

When I tested my library module during development, it was successful. However, after it was published on github and hosted on jitpack, I called the same function from the SDK, which contains the encryption code, and it consistently produced this problem.

The suspected issue is with the '@aar' thing, is there anything special required to have this dependency in a library module?

photo_2023-05-18 16 41 49

gurpreet- commented 1 year ago

Hi @aagam-chai,

I think all you need to do to the consuming project is add JNA to it...

implementation "net.java.dev.jna:jna:5.13.0@aar"
KamilKalfas commented 1 year ago

Hi @gurpreet-

I have same issue.

My SDK uses

api "com.goterl:lazysodium-android:5.1.0@aar"
implementation "net.java.dev.jna:jna:5.13.0@aar"

Then in consumer app when : 1)

 implementation project(path: ":my-sdk")

it WORKS

2)

implementation 'com.example.org:my-sdk:version'

Runtime exception

FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 10753
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path (.)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1059)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015)
at com.sun.jna.Native.<clinit>(Native.java:221)
at com.sun.jna.Native.register(Native.java:1773)
at com.goterl.lazysodium.SodiumAndroid.<init>(SodiumAndroid.java:36)
at com.goterl.lazysodium.SodiumAndroid.<init>(SodiumAndroid.java:17)

3)

implementation 'com.example.org:my-sdk:version'
implementation "net.java.dev.jna:jna:5.13.0@aar"

Compile exception

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable

Any suggestions?

fluxxion82 commented 9 months ago

I see this as well in my project. I've added the jna library as a dependency but it still doesn't work for some reason.

langme commented 1 month ago

Already open I have the same issue with

api "com.goterl:lazysodium-android:5.1.0@aar"
implementation "net.java.dev.jna:jna:5.13.0@aar"

jna = "5.13.0" kotlin = "2.0.20"