简体   繁体   中英

No JNI library to link to on android toolchain

There seems to be "jni.h" header in the android toolchain but no library to link to.

Can somebody guide me how can I invoke Java functions from C code in my app?

Android does not export a JNI library. This means that there is no way in the system to call JNI_CreateJavaVM() and her ilk from user-space C code. You can create your own JVM, but it will not be the same Java, and won't have access to Android SDK classes and methods.

In Android, a Zigote process is started with a special JVM (Dalvik or ART), and then Java can load your C code (in form of .so files), not vice versa.

Your C code can use the standard JNI techniques like CallVoidMethod() and her kin to invoke Java methods. Note that Android SDK Java methods often need some 'handles', like context , to have their work done; usually, you must rely on some calls from Java to C that will give you these handles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM