JAVAH can't find class( android ndk)

微笑、不失礼 提交于 2019-11-29 03:47:36

The ant part of the Android build system actually places the class files in bin/classes. So you need to have $PROJECT_DIRECTORY/bin/classes on the javah classpath. For example, from the src directory you could run:

$PROJECT_DIRECTORY/src$ javah -classpath ../bin/classes bt.nativeclient.BtnativeActivity

This assumes that you've compiled your Java code to the corresponding class files first. You can check by seeing what is in the bin/classes directory - it should contain the bt directory, which is the top of your package name.

In my case the problem was that the Windows Java was in the path before the Android java. So check (in cygwin) which javah you are using (which javah), and if the path doesn't look right, fix the path.

in my case I had to rename my package from 'com.examples.cam' to something else. Then javah worked properly. Before I had the same "class not found" error.

@richq is absolutely right. But there is one more thing that I would like to add. (And which has taken up most of my morning solving that)

While specifying the classpath = Refrain from using ./bin/classes:~/ProjectFolder/bin/classes ( the tilde representing the Home directory)

But use the "../../" to switch directories. For some reason javah doesn't recognizes the tilde operator for the home directory.

Also one other thing if the class has a dependency on other project then you would need that as well in the classpath

user@laptop:~/SomeProject javah -classpath ./bin/classes:../<Whereever the path is>/SomeOtherDependentProject:../<Path to android-sdk>/android.jar <Qualified class path>

Even I was stuck with this for a while and answer that richq worked like a charm. I would like to add that in classpath you should only provide the path till the start of your package (most projects its one level before com). For the next argument give class file path inside your packages (ie starting from com.mypackage.myclass) Also, do not append the class name with '.java' extention.

from 'src' of your package

javah -classpath ../package1/package2/.. com.mypackage.myclassname

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