JAVAH错误android.app.Activity未找到 [英] Javah Error android.app.Activity not found
问题描述
我试图创建一个简单的NDK项目的.h头文件。使用Cygwin我浏览到 myprojectDIR \ JNI
目录下,然后执行此命令:
I'm trying to create a .h header file for a simple NDK project. Using cygwin I browse to myprojectDIR\jni
directory, then execute this command:
javah -o com_myproject_MyActivity.h -classpath myprojectDIR\bin\classes 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,构建和测试的设备,其中成功了!
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 64位),我有这些环境变量:
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:\Android\android-ndk-r7b
ANDROID_SDK : C:\Android\android-sdk
ANT_HOME : C:\ANT\apache-ant-1.8.3
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_02
PATH : %JAVA_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%ANDROID_NDK%;%ANT_HOME%\bin; (other unrelated stuff)
在此先感谢
推荐答案
尝试添加到您的类路径:
Try adding to your classpath:
-classpath <android-sdk-location>/platforms/android-8.jar
这篇关于JAVAH错误android.app.Activity未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!