3

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.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Prashant Singh
  • 3,725
  • 12
  • 62
  • 106
  • Check this out http://stackoverflow.com/questions/10483959/javah-error-android-app-activity-not-found/25989225#25989225 – Punith K Sep 23 '14 at 07:34

4 Answers4

2

You seem to be missing a separator on your classpath:

javah -classpath /cygdrive/c/Android/android-sdk/platforms/android.jar:myNDK/bin/classes my.first.NDK.MyNDKActivity
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Still getting the same error 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. – Prashant Singh Oct 06 '12 at 14:23
  • This error msg would suggest that your classpath is incorrect. From the current directory, do `ls myNDK/bin/classes`, can you see your `my` folder? – Reimeus Oct 06 '12 at 14:28
  • I can see 'my' folder, but that takes me to outside of my project folder. Is that OK ? I think I need to stay in my bin folder ? – Prashant Singh Oct 06 '12 at 14:34
  • Thanks for help(+1) ! I had issue with my class path – Prashant Singh Oct 06 '12 at 16:00
1

What is android.jar is doing in your line?!

Also, MyNDKActivity is the class which contains native signatures?

I used javah in this form (its works for me):

javah -d output/ -classpath /home/bod/path/to/eclipse/workspace/project/classes com.myapp.NDKBridge

where:

-d output/ is directory to collect generated headers

-classpath /home/.../classes - folder with classes in your project

com.myapp.NDKBridge - name of class which declare native signatures.

Sergey Vakulenko
  • 1,655
  • 18
  • 23
1

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

Prashant Singh
  • 3,725
  • 12
  • 62
  • 106
1

maybe it can work!add the option [-bootclasspath] of your sdk path.

javah -bootclasspath /home/lmdyyh/development/adt-bundle-linux-x86-20131030/sdk/platforms/android-19/android.jar -classpath bin/classes -d jni com.myndk.Myndk