lambdapioneer / argon2kt

An Android/Kotlin binding for the Argon2 hash
MIT License
78 stars 8 forks source link

1.5.0 Crash: SystemSoLoader.loadLibrary; java.lang.UnsatisfiedLinkError - dlopen failed: library "libargon2jni.so" not found #25

Open NickMelnykIronvest opened 2 months ago

NickMelnykIronvest commented 2 months ago

SystemSoLoader.loadLibrary java.lang.UnsatisfiedLinkError - dlopen failed: library "libargon2jni.so" not found com.lambdapioneer.argon2kt SoLoader.kt:13

v 1.5.0

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.hidden-HIDDEN==/base.apk"],nativeLibraryDirectories=[/data/app/com.hidden-HIDDEN==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]] couldn't find "libargon2jni.so"
       at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
       at java.lang.System.loadLibrary(System.java:1660)
       at com.lambdapioneer.argon2kt.SystemSoLoader.loadLibrary(SoLoader.kt:13)
       at com.lambdapioneer.argon2kt.Argon2Jni.<init>(Argon2Jni.kt:15)
       at com.lambdapioneer.argon2kt.Argon2Kt.<init>(Argon2Kt.kt:61)
       at com.lambdapioneer.argon2kt.Argon2Kt.<init>(Argon2Kt.kt:60)

second variant:

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libargon2jni.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
       at java.lang.Runtime.loadLibrary0(Runtime.java:998)
       at java.lang.System.loadLibrary(System.java:1656)
       at com.lambdapioneer.argon2kt.SystemSoLoader.loadLibrary(SoLoader.kt:13)
       at com.lambdapioneer.argon2kt.Argon2Jni.<init>(Argon2Jni.kt:15)
       at com.lambdapioneer.argon2kt.Argon2Kt.<init>(Argon2Kt.kt:61)
       at com.lambdapioneer.argon2kt.Argon2Kt.<init>(Argon2Kt.kt:60)

Devices: 86% Transsion - Unisoc 14% Huawei

Operating systems: 86% Android 12 14% Android 8

P.S. have not tried newer version 1.6.0. Thus I am not sure whether it is applicable to versions above 1.5.0.

lambdapioneer commented 2 months ago

Hey, thanks for raising the issue.

The underlying reason is likely that the system's SoLoader on those devices is behaving a bit weirdly. That's a known issue with native libraries on Android with some devices (often from smaller brands). There should be no difference between version 1.6.0 and 1.5.0 of Argon2Kt.

The Argon2Kt() method allows providing a custom SoLoader for exactly this reason: Argon2Kt(soLoader: SoLoaderShim). Using the SoLoader from Facebook (also used by React Native) is a good choice: https://github.com/facebook/SoLoader/tree/main

On your part, you'd need to include that dependency and then implement com.lambdapioneer.argon2kt.SoLoaderShim (just one method) for the com.facebook.soloader.SoLoader. You probably just create a new class FacebookSoLoaderShim. Then you initialize that new object and pass it into the Argon2Kt constructor.

Let me know if you get stuck or like some more specific sample code.

lambdapioneer commented 2 months ago

HI @NickMelnykIronvest, just wanted to quickly check if you had a chance to test the mitigation and whether it had any effect. If you have questions, let me know.