Android

145 views
Skip to first unread message

Cristi Ursachi

unread,
Jan 18, 2015, 8:49:43 AM1/18/15
to lmd...@googlegroups.com
Does anybody port it to Android?

Kristoffer Sjögren

unread,
Jan 18, 2015, 9:07:53 AM1/18/15
to lmd...@googlegroups.com
Not that i'm aware of. Not really familiar with Android development but I suspect that lmdbjni-x64 would work on 64-bit Android?

Have you tried it?

Kristoffer Sjögren

unread,
Jan 18, 2015, 11:10:15 AM1/18/15
to lmd...@googlegroups.com
So LMDB runs on Android. AFAICT there needs to be a separate lmdbjni build using Android NDK. I will look into it and see if we can deliver an android artifact as well.

https://github.com/deephacks/lmdbjni/issues/16

Cristi Ursachi

unread,
Jan 18, 2015, 2:15:09 PM1/18/15
to lmd...@googlegroups.com
Hello Kristoffer,
Yes I tried but does not work because Android NDK is not compatible with  org.fusesource.hawtjni, at least at first look, we'll look deeply too, just wanted to know if somebody tried. Would be really great if you can deliver JNI for Android too.

Kristoffer Sjögren

unread,
Jan 18, 2015, 5:47:04 PM1/18/15
to lmd...@googlegroups.com
I managed to build lmdb for Android using arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc and android 19.

If I understand correctly ARM instruction set runs on most Android devices?

Cristi Ursachi

unread,
Jan 19, 2015, 4:59:40 AM1/19/15
to lmd...@googlegroups.com
Indeed, ARM binaries runs on most devices, I managed to compile and generate .so file too, but still have problem with JNI wrappers, it says:
No implementation found for void lmdbjni.JNI.init() (tried Java_lmdbjni_JNI_init and Java_lmdbjni_JNI_init__)
01-19 11:42:55.471: E/art(1033): --------- beginning of crash
01-19 11:42:55.490: E/AndroidRuntime(1033): FATAL EXCEPTION: Thread-119
01-19 11:42:55.490: E/AndroidRuntime(1033): Process: com.example.android.keychain, PID: 1033
01-19 11:42:55.490: E/AndroidRuntime(1033): java.lang.UnsatisfiedLinkError: No implementation found for void lmdbjni.JNI.init() (tried Java_lmdbjni_JNI_init and Java_lmdbjni_JNI_init__)
01-19 11:42:55.490: E/AndroidRuntime(1033):  at lmdbjni.JNI.init(Native Method)
01-19 11:42:55.490: E/AndroidRuntime(1033):  at lmdbjni.JNI.<clinit>(JNI.java:35)
01-19 11:42:55.490: E/AndroidRuntime(1033):  at lmdbjni.Env.create(Env.java:43)
01-19 11:42:55.490: E/AndroidRuntime(1033):  at lmdbjni.Env.<init>(Env.java:37)

Kristoffer Sjögren

unread,
Jan 19, 2015, 5:13:34 AM1/19/15
to lmd...@googlegroups.com
What modifications did you do to lmdbjni to make it build? Did you use the existing linux64 project as a base or something else entirely?

Cristi Ursachi

unread,
Jan 19, 2015, 5:22:51 AM1/19/15
to lmd...@googlegroups.com
I built it using Visual Studio 2015 Preview version(it has Android native support). Just put LMDB C files and worked, we even tested it and worked(but fully native app). So problems seems to be on JNI wrappers.

Kristoffer Sjögren

unread,
Jan 19, 2015, 5:31:27 AM1/19/15
to lmd...@googlegroups.com
Yes, I think a proper build using the lmdbjni build scripts is needed. I did some work on this last night and may be able to provide a SNAPSHOT jar later tonight.

Would you be able to test it if I send it to you? It would be much faster since I don't have an Android environment running.

Cristi Ursachi

unread,
Jan 19, 2015, 5:35:05 AM1/19/15
to lmd...@googlegroups.com
Sure, I'm willing to test it!

Kristoffer Sjögren

unread,
Jan 19, 2015, 2:41:34 PM1/19/15
to lmd...@googlegroups.com
I think this is proper build. Please try it out and let me know how it goes.

Kristoffer Sjögren

unread,
Jan 19, 2015, 2:43:25 PM1/19/15
to lmd...@googlegroups.com

Cristi Ursachi

unread,
Jan 20, 2015, 3:43:12 AM1/20/15
to lmd...@googlegroups.com
Thanks Kristoffer,
It seems that now it successfully load the .so and it can access native methods, but there is a problem reading a MDB error content; I get this error:

01-20 09:52:53.476: E/AndroidRuntime(1461): FATAL EXCEPTION: Thread-164
01-20 09:52:53.476: E/AndroidRuntime(1461): Process: com.example.android.keychain, PID: 1461
01-20 09:52:53.476: E/AndroidRuntime(1461): java.lang.NoSuchMethodError: No virtual method addressSize()I in class Lsun/misc/Unsafe; or its super classes (declaration of 'sun.misc.Unsafe' appears in /system/framework/core-libart.jar)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.Unsafe.<clinit>(Unsafe.java:26)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.NativeBuffer.read(NativeBuffer.java:190)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.NativeBuffer.toByteArray(NativeBuffer.java:198)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.Util.string(Util.java:34)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.Util.checkErrorCode(Util.java:39)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.Env.open(Env.java:59)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.Env.open(Env.java:51)
01-20 09:52:53.476: E/AndroidRuntime(1461):  at org.fusesource.lmdbjni.Env.open(Env.java:47)


So it seems that some methods are missing from Unsafe class on Android.

Cristi

Cristi Ursachi

unread,
Jan 21, 2015, 4:19:07 AM1/21/15
to lmd...@googlegroups.com
Thanks to Kristoff for the great work, the latest version from GitHub works on Android.

Kristoffer Sjögren

unread,
Jan 21, 2015, 5:19:52 AM1/21/15
to lmd...@googlegroups.com
No problem, thanks for helping testing it. I will make an official 0.2.7 release which include the android artifact.

Reply all
Reply to author
Forward
0 new messages