Javah: Error: cannot access android.support.v7.app.ActionBarActivity

流过昼夜 提交于 2019-12-07 10:17:00

问题


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.


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/28385146/javah-error-cannot-access-android-support-v7-app-actionbaractivity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!