UnsatisfiedLinkError in Android
I'm trying to use this library in Android. To import it, I use this in build.gradle:
dependencies{
implementation group: 'net.iakovlev', name: 'timeshape', version: '2020d.12'
}
Then I use it in my Java code like this:
import net.iakovlev.timeshape.TimeZoneEngine;
TimeZoneEngine engine = TimeZoneEngine.initialize();
This compiles just fine, but it crashes at runtime with the following error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.my_app, PID: 4629
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.my_app-CnG68M7pV_GWaAOEveKg9Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my_app-CnG68M7pV_GWaAOEveKg9Q==/lib/arm, /system/lib, /product/lib]]] couldn't find "libzstd-jni-1.5.0-4.so"
Unsupported OS/arch, cannot find /linux/armv7l/libzstd-jni-1.5.0-4.so or load zstd-jni-1.5.0-4 from system libraries. Please try building from source the jar or providing libzstd-jni-1.5.0-4 in your system.
at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.github.luben.zstd.util.Native.load(Native.java:87)
at com.github.luben.zstd.util.Native.load(Native.java:55)
at com.github.luben.zstd.ZstdInputStreamNoFinalizer.<clinit>(ZstdInputStreamNoFinalizer.java:23)
at com.github.luben.zstd.ZstdInputStream.<init>(ZstdInputStream.java:24)
at net.iakovlev.timeshape.TimeZoneEngine.initialize(TimeZoneEngine.java:235)
at net.iakovlev.timeshape.TimeZoneEngine.initialize(TimeZoneEngine.java:153)
Hi!
Thanks for reporting this. I've not tested Timeshape on Android, so I don't have an answer right off the bat. However, looking at the stack trace you've provided, it seems the problem is with the zstd-jni library.
Could you please try and follow the procedure to add zstd-jni on Android (described here: https://github.com/luben/zstd-jni#android-support) and see if it makes any difference?
I had the same issue.
If it helps someone, simply adding
implementation 'com.github.luben:zstd-jni:1.5.2-3@aar'
to build.gradle as described in the above link led to duplicate class errors. Instead I used
// Timeshape
implementation('net.iakovlev:timeshape:2020d.12') {
// Exclude standard compression library
exclude group: 'com.github.luben', module: 'zstd-jni'
}
// Import aar for native component compilation
implementation 'com.github.luben:zstd-jni:1.5.2-3@aar'
Thanks for the detailed explanation! Would you mind adding it to readme? Seems really useful for people running Timeshape on Android.
Closing based on lack of activity. Hopefully the instructions in readme now provide a clear path to run Timeshape on Android.