JNI
Developing Android apps ? Ever thought about developing a bit with the NDK (throw some C/C++ with your Java code) ? Then you have to know your JNI (the way Java interfaces with C/C++ since Java 2 – 1997).
Just finished my HelloWorld and wanted to share bottom liners that might go boom-boom.
In order to get started I read the following: 1, 2.
Another general source is the classic book: The Java Native Interface (download link).
Following the guides, trying to run java HelloWorld I’ve encountered the following exception:
Exception in thread “main” java.lang.UnsatisfiedLinkError: no HelloWorld in
java.library.pathat java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)at java.lang.Runtime.loadLibrary0(Runtime.java:849)at java.lang.System.loadLibrary(System.java:1088)at HelloWorld.<clinit>(HelloWorld.java:9)
Cause:
libtool -dynamic -lSystem HelloWorldJniSample.o -o HelloWorldJniSample.jnilib
On the mac, JNI libraries should start with the prefix lib, which wasn’t stated anywhere in the links I’ve provided.
Fix:
libtool -dynamic -lSystem HelloWorldJniSample.o -o libHelloWorld.jnilib
That’s it folks. More to come!
Later post I’ll described how I’ve built the Android eco system, a.k.a AOSP.
yuw ezo
LikeLike