Android NDK: Eclipse parameter and javah

混江龙づ霸主 提交于 2019-12-06 08:48:55

try adding

-classpath bin/classes

as parameter to javah

Avinash Chandra

Specially for Android:

use classes right after bin like project_location/bin/classes, this worked for me on Linux Fedora

javah -d /var/www/project/jni/ -classpath /var/www/project/bin/classes/ com.android.TestClass

@BlackBelt - thanks man for your suggestion!

Here is the parameter that worked, solving the javah side for the compiling process:

-d ${workspace_loc:/Dev/jni} com.pkgpub.Dev -classpath ${workspace_loc:/Dev/bin/classes/} com.pkgpub.Dev

Where pkgpub is the package name, and Dev is the project name. It is worth to mention that the project has the files: \src\Dev.java; \jni\Dev.c; \jni\Dev.h; \bin...\pkgpub\Dev.class.

Now it generates the file jni/com_pkgpub_Dev.h with the right content. Which is great!

However the ndk-build is still not completely linking, and does not generate the com_pkgpub_Dev.c file. So, from Project > Project Build - comes the message:

**** Build of configuration Build (GNU) for project Dev ****
ndk-build 
make: *** No rule to make target `jni/com_pkgpub_Dev.c', needed by `obj/local/armeabi/objs/dev/com_pkgpub_Dev.o'.  Stop.
**** Build Finished ****

From this message it sounds like some parameter should be missing from the file /jni/Android.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS    := -DHAVE_INTTYPES_H
LOCAL_MODULE    := dev
LOCAL_SRC_FILES := com_pkgpub_Dev.c Dev.c
include $(BUILD_SHARED_LIBRARY) 

To solve it, it is just necessary to create the missing file "jni/com_pkgpub_Dev.c". This file content should be manually made based on the automatic generated code contained in the file "jni/com_pkgpub_Dev.h".

Now, it works!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!