Javah Error android.app.Activity not found

2,366 views
Skip to first unread message

ayesh qumhieh

unread,
May 7, 2012, 10:14:07 AM5/7/12
to andro...@googlegroups.com
Hello
I have a problem with NDK, I think it is strange because until now haven't seen this happening any where or with any one else but with me.

I'm trying to create a .h header file for a simple NDK project, using cygwin :

using cygwin I browse to <myproject>\jni directory, then execute this command
javah -o com_myproject_MyActivity.h -classpath  <myproject>\bin\classes com.myproject.MyActivity

then this error message appears:
Error: cannot access android.app.Activity
  class file for android.app.Activity not found

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 devise where successful !!!!

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 it self, 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>

thanks in advance

John.zhou

unread,
May 14, 2012, 7:39:41 AM5/14/12
to android-ndk


On 5月7日, 下午10时14分, ayesh qumhieh <ayeshqumh...@gmail.com> wrote:
> Hello
> I have a problem with NDK, I think it is strange because until now haven't
> seen this happening any where or with any one else but with me.
>
> I'm trying to create a .h header file for a simple NDK project, using
> cygwin :
>
> using cygwin I browse to *<myproject>**\jni* directory, then execute this
> command
> *javah -o com_myproject_MyActivity.h -classpath  **<myproject>\**bin\classes
> com.myproject.MyActivity*
>
> then this error message appears:
> Error: cannot access android.app.Activity
>   class file for android.app.Activity not found
>
> 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
> devise where successful !!!!
>
> 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 it self, 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_N­DK%;%ANT_HOME%\bin;
> <other unrelated stuff>
>
> thanks in advance
>
>
OK,I have the same problem with you. Do you know how to solve the
problem now? Please tell me , thinks in advance.

David Turner

unread,
May 14, 2012, 1:59:15 PM5/14/12
to andro...@googlegroups.com
I guess you should put the platforms' android.jar in your classpath too.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


ayesh qumhieh

unread,
May 18, 2012, 10:27:23 AM5/18/12
to andro...@googlegroups.com
I found how finally, it goes like this:
    javah -o com_myproject_MyActivity.h -classpath <android-sdk-location>/platforms/android-8.jar;myprojectDIR\bin\classes com.myproject.MyActivity
Reply all
Reply to author
Forward
0 new messages