JAVAH 找不到类( android ndk)
2022-09-04 07:16:55
我需要javah和android-ndk的帮助。
我试图为我的本机方法生成H文件,但javah说找不到类文件。
我的目标类的绝对名称$PROJECT_DIRECTORY/src/bt/nativeclient/BtnativeActivity.java并包含以下代码:
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");
}
}
我试图从以下路径启动javah:
$(PROJECT_DIRECTORY)/bin$ javah -jni bt.nativeclient.BtnativeActivity
$(PROJECT_DIRECTORY)/jni$ javah -jni bt.nativeclient.BtnativeActivity
$(PROJECT_DIRECTORY)$ javah -jni bt.nativeclient.BtnativeActivity
我试图指定 -classpath 路径:
$PROJECT_DIRECTORY/src$ javah -classpath :. bt.nativeclient.BtnativeActivity
我试图指定android.jar如上所述:
$PROJECT_DIRECTORY/bin$ javah -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.
Error: No classes were specified on the command line. Try -help.
此外,使用-verbose选项命令javah说这个命令正在搜索我的类,它是有效的地方:
$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.
我想我失去了一些重要的东西,但我仍然找不到解决方案。
任何人都可以帮我吗?