Javah 错误 android.app.Activity 未找到 [英] Javah Error android.app.Activity not found

查看:26
本文介绍了Javah 错误 android.app.Activity 未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为一个简单的 NDK 项目创建一个 .h 头文件.使用 cygwin 我浏览到 myprojectDIRjni 目录,然后执行以下命令:

I'm trying to create a .h header file for a simple NDK project. Using cygwin I browse to myprojectDIRjni directory, then execute this command:

javah -o com_myproject_MyActivity.h -classpath  myprojectDIRinclasses com.myproject.MyActivity

然后出现这个错误信息:

then this error message appears:

Error: cannot access android.app.Activity
class file for android.app.Activity not found

我在 MyActivity 类中有一个本地方法,所以我尝试创建一个名为 NativeAccess 的新类(不从 android SDK 扩展任何类)并且它有效好的,.h 文件已创建,ndk-build 并在成功的设备上测试!

I have a native method inside MyActivity class, so I tried to create a new class called NativeAccess (does not extend any class from the android SDK) and it worked fine, the .h file was created, ndk-build and test on device where successful!

所以我的问题是我需要在我创建的 android 活动和服务中使用本机方法,但我不能这样做,因为 Javah 命令无法从 android-sdk 本身内部访问类.请注意我使用的是 (Windows-7 x64) 并且我有这些环境变量:

So my problem is that I need my native methods inside android activities and services that I create, but I cant do that because the Javah command cannot access classes from inside the android-sdk itself. Please notice that I'm using (Windows-7 x64) and I have these environment variables:

ANDROID_NDK : C:Androidandroid-ndk-r7b
ANDROID_SDK : C:Androidandroid-sdk
ANT_HOME    : C:ANTapache-ant-1.8.3
JAVA_HOME   : C:Program FilesJavajdk1.7.0_02
PATH        : %JAVA_HOME%in;%ANDROID_SDK%	ools;%ANDROID_SDK%platform-tools;%ANDROID_NDK%;%ANT_HOME%in; (other unrelated stuff)

提前致谢

推荐答案

尝试添加到你的类路径:

Try adding to your classpath:

-classpath <android-sdk-location>/platforms/android-8.jar

这篇关于Javah 错误 android.app.Activity 未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆