JAVAH找不到类(安卓NDK) [英] JAVAH can't find class( android ndk)
问题描述
我需要javah的和Android的NDK。
I need a help in javah and android-ndk.
我tryed生成H-文件,我的本地方法,但 javah的说没有发现的类文件
I tryed to generate H-file for my native method, but javah said class file not found.
我的目标类有绝对的名字$ PROJECT_DIRECTORY / 的src / BT / nativeclient / BtnativeActivity.java 并包含按照code:
My target class has absolute name $PROJECT_DIRECTORY/src/bt/nativeclient/BtnativeActivity.java and contains follow code:
package bt.nativeclient;
import android.app.Activity; import android.os.Bundle; import android.widget.TextView;
public class BtnativeActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText( stringFromJNI() );
setContentView(tv);
}
public native String stringFromJNI();
static
{
System.loadLibrary("hello-jni");
}
}
我tryed启动 javah的从如下pathes:
I tryed to start javah from follows pathes:
$(PROJECT_DIRECTORY)/bin$ javah -jni bt.nativeclient.BtnativeActivity
$(PROJECT_DIRECTORY)/jni$ javah -jni bt.nativeclient.BtnativeActivity
$(PROJECT_DIRECTORY)$ javah -jni bt.nativeclient.BtnativeActivity
我tryed指定的 -classpath pathes:
$PROJECT_DIRECTORY/src$ javah -classpath :. bt.nativeclient.BtnativeActivity
我tryed指定的android.jar 作为提及有:
$PROJECT_DIRECTORY/bin$ javah -classpath :/home/l/android-sdks/platforms/android-10/android.jar:. bt.nativeclient.BtnativeActivity
不过,我总是得到结果只有一个:
But always I get only one result:
error: cannot access bt.nativeclient.BtnativeActivity
class file for bt.nativeclient.BtnativeActivity not found
javadoc: error - Class bt.nativeclient.BtnativeActivity not found.
Error: No classes were specified on the command line. Try -help.
另外,是 -verbose 选项命令 javah的说,该命令seaching我的课是有效的地方:
Moreover, with -verbose option command javah says that this command was seaching my class it the valid place:
$PROJECT_DIRECTORY/src$ javah **-verbose** -classpath :/home/l/android-sdks/platforms/android-10/android.jar:. bt.nativeclient.BtnativeActivity
error: cannot access bt.nativeclient.BtnativeActivity
class file for bt.nativeclient.BtnativeActivity not found
javadoc: error - Class bt.nativeclient.BtnativeActivity not found.
[ Search Path: /usr/lib/jvm/java-6-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/netx.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/plugin.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/modules/jdk.boot.jar:/usr/lib/jvm/java-6-openjdk/jre/classes/:/home/l/android-sdks/platforms/android-10/android.jar:. ]
Error: No classes were specified on the command line. Try -help.
我想我已经失去了一些重要的事情,但我仍然无法找到解决方案。
I think I have lost some important thing, but I still can't find resolution.
可能有人帮助我,好吗?
Could anybody help me, please?
推荐答案
在Android构建系统的一部分蚂蚁居然会将类文件中斌/班
。所以,你需要有 $ PROJECT_DIRECTORY /斌/班
在 javah的
类路径。例如,从src目录,你可以运行:
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
这假定您已经编译你的Java code到相应的类文件第一。您可以通过检查看到的是在bin / classes目录 - 它应该包含 BT
目录,这是你的包名上方
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.
这篇关于JAVAH找不到类(安卓NDK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!