ant ant - 1 month ago 6
Android Question

Generate C header file (*.h) for native method implementation JNI in android studio

How to generate C header file (*.h) containing the function prototype for the native method implementation JNI in Android studio while build automatically?

Thank You


Assume you have a project HelloNative

   |-build/intermediate/classes/debug  (you get this directory upon project build)

And you want to generate the header file for --> do this

cd HelloNative

javah -d app/src/main/jni -classpath /Users/john-smith/Android/sdk/platforms/android-19/android.jar:app/build/intermediates/classes/debug com.planets.mercury.HelloNativeActivity

Replace john-smith and android sdk path with what it is on your own machine. For the android jar file. You can use whatever is your choice.

Eg. android-19, or android-21