Search code examples
androidandroid-ndkjavah

javah error : cannot access activity


I was trying to make a .h file using Javah for my Android NDK application.I am using cygwin to do the same for me.

Fixing the workspace to bin folder of my current application, I executed this command :-

javah -classpath /cygdrive/c/Android/android-sdk/platforms/android.jar myNDK\bin\classes my.first.NDK.MyNDKActivity

However, it is consistently giving the following error :-

error: cannot access myNDKbinclasses
class file for myNDKbinclasses not found
javadoc: error - Class myNDKbinclasses not found.
error: cannot access my.first.NDK.MyNDKActivity
class file for my.first.NDK.MyNDKActivity not found
javadoc: error - Class my.first.NDK.MyNDKActivity not found.
Error: No classes were specified on the command line.  Try -help.

Can anyone help me in solving this issue ?

I also tried to go to the folder containing the java file and execute the javah there, but still I was getting same error :-

error: cannot access MyNDKActivity
class file for MyNDKActivity not found
javadoc: error - Class MyNDKActivity not found.
Error: No classes were specified on the command line.  Try -help.

That somehow depicts the problem is due to some permission problem, I guess.


Solution

  • Finally, I resolved my issue. There was a problem with the classpath I was using. Here goes the final solution :-

    1. Where to execute the command from $PROJECT_DIRECTORY/src

    2. The ant part of the Android build system actually places the class files in bin/classes. So the classpath should be of form $PROJECT_DIRECTORY/bin/classes

    3. javah -classpath ../bin/classes my.first.NDK.MyNDKActivity