4

I have a problem with javah, I have read about 4 or 5 stakcoverflow posts with the error "solved" but anything works for me.

My problem:

When i execute the javah command i have this error:

Error: cannot access android.support.v7.app.ActionBarActivity
  class file for android.support.v7.app.ActionBarActivity not found

What I have tried:

This is the command that I have tested:

C:\Users\MyUser\workspace3\PruebaApp\jni\include>javah -classpath ../../bin/classes;C:\Users\MyUser\AppData\Local\Android\sdk\platforms\android-14\android.jar -o ACK.h com.test.prueba.ACK

I have tried too the same command with only "/" and only "\" for separating direcotries.

I have tried it with android-11, android-14, and android-21.

I have tried to add the following external jars to my project: "android-support-v4.jar" and "android-support-v7-appcompat.jar"

I have tried to do it creating a external build configuration with eclipse, like here: Javah Error android.app.Activity not found

Tools I'm using

I'm working with eclipse juno, on windows 8.1.

The folder from which I executed the command is {project_dir}/jni/include. I have tried it from different folders, modifying the command correctly.

The .java file that contains the native function is "ACK.java" in the package: "com.test.prueba"

In the project, the android library that I'm using is android 5.0.1

What can I do? Thanks in advance.

Community
  • 1
  • 1
Dan
  • 2,452
  • 20
  • 45
  • 2
    I have "solved" my problem. I have put the absolut paths to the missing files: "android-support-v7-appcompat" and "android-support-v4". The result javah command is: javah -classpath ../../bin/classes;/sdk/platforms/android-14/android.jar;/sdk/extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar;/sdk/extras/android/support/v7/appcompat/libs/android-support-v4.jar -o X.h com.test.prueba.ACK. But the problem is still being that i need to write all above, why? – Dan Feb 07 '15 at 19:07

3 Answers3

9

The native methods declared in your java class is enough for generating JNI header. In your example, the command javah's option -classpath is not very useful. Suppose com/test/prueba/ACK.java is the class you process to generate JNI header. You can change the working directory to {project_dir}\src, execute the command

javah com.test.prueba.ACK

the corresponding JNI header file com_test_prueba_ACK.h will be created in the current directory.

alijandro
  • 11,627
  • 2
  • 58
  • 74
2

You should write full path of android-support-v7-appcompat.jar and android-support-v4.jar in classpath parameter.

Alex
  • 419
  • 1
  • 5
  • 24
0

Please have a look to my answer https://stackoverflow.com/a/52527212/2573138 which integrates in Android Studio the way described by enter image description herealijandro.

Matteo
  • 482
  • 3
  • 11