代码拉取完成,页面将自动刷新
step 1: add source file step 2: add makefile and build shared object err: ➜ ./main ./main: error while loading shared libraries: libmyjni.so: cannot open shared object file: No such file or directory fix: export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH step 3: how to use libmyjni.so in java method a.step 1 load library b.step 2 add native method to call c method err: javac JniTest.java java JniTest hello jni Exception in thread "main" java.lang.UnsatisfiedLinkError: JniTest.sum_c(II)I at JniTest.sum_c(Native Method) at JniTest.main(JniTest.java:8) why? no map in java native method and c shared object. fix: new c file to map java native method and c function. we often call this operation JNI-java native interface err: native_jni.c:1:17: fatal error: jni.h: 没有那个文件或目录 fix: add -I arg gcc -I/usr/lib/jvm/java-8-openjdk-amd64/include/ step 4: static register jni method a. javac JniTest.java b. javah -jni JniTest //auto create JniTest.h c. include JniTest.h in native_jni.c step 5: just only one so lib step 6: add android project step 7: use jni lib in android project step 8: support ndk build for android project
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。