Android 生成 jni 標頭檔案
阿新 • • 發佈:2019-01-08
工程目錄結構如下:
DataEncrypt 檔案內容如下:
public class DataEncrypt {
public native byte[] decodeBuffer(byte data[], int len);
static {
System.loadLibrary("ldencrypt");
}
}
generate_java_head_file.sh 檔案內容如下:
#!/usr/bin/env bash # packagename.classname TARGET_CLASS_NAME="包名.DataEncrypt" PROJECT_PATH=`cd ../ && pwd` SOURCE_PATH="${PROJECT_PATH}/java" TARGET_PATH="${PROJECT_PATH}/jni" cd "${SOURCE_PATH}" javah -d ${TARGET_PATH} -classpath "${SOURCE_PATH}" "${TARGET_CLASS_NAME}"
命令列執行./generate_java_head_file.sh, 即可生成對應的.h檔案