Run javah to generate JNI C header files. #115

Merged
merged 3 commits into from Feb 8, 2012

Projects

None yet

2 participants

@mkneissl
mkneissl commented Feb 8, 2012

When using JNI one typically uses javah to generate a C header containing the constants and function declarations for classes that contain native methods.

This patch lets SBT run javah to generate the header file for a given set of classes.

Setting jniClasses in Android specifies the classes with native methods for which C headers should be generated.

By default, javah will generate a separate C header file for each JNI class. To generate a single C header file instead, set javahOutputFile in Android.

The make environment variable SBT_MANAGED_JNI_INCLUDE can be used to refer to the directory containing the generated header files.

# Android.mk
LOCAL_C_INCLUDES += \
        ... \
        $(SBT_MANAGED_JNI_INCLUDE)

For more details see the settings defined in AndroidNdkKeys.

@mkneissl
Owner

Basic usage

When using JNI one typically uses javah to generate a C header containing the constants and function declarations for classes that contain native methods.

This patch lets SBT run javah to generate the header file for a given set of classes.

Setting jniClasses in Android specifies the classes with native methods for which C headers should be generated.

The make environment variable SBT_MANAGED_JNI_INCLUDE can be used to refer to the directory containing the generated header files.

# Android.mk
LOCAL_C_INCLUDES += \
        ... \
        $(SBT_MANAGED_JNI_INCLUDE)
@jberkel jberkel merged commit 053ca2d into jberkel:master Feb 8, 2012
Owner
jberkel commented Feb 8, 2012

Thanks! If you've got some time could you update the wiki?
https://github.com/jberkel/android-plugin/wiki/Building-NDK-Projects

mkneissl commented Feb 8, 2012

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment