Categories
android

android so 编译(笨方法)

定义java native文件

package com.robin.spot.jni;

public class WiringOP {

    static {
        System.loadLibrary("WiringOP");
    }

    public final static native int wiringPiSetup();
    
}

生成java native 头文件

 javac -h ./ .\com\robin\spot\jni\WiringOP.java

头文件内容

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_robin_spot_jni_WiringOP */

#ifndef _Included_com_robin_spot_jni_WiringOP
#define _Included_com_robin_spot_jni_WiringOP
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     com_robin_spot_jni_WiringOP
 * Method:    wiringPiSetup
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_com_robin_spot_jni_WiringOP_wiringPiSetup
  (JNIEnv *, jclass);

#ifdef __cplusplus
}
#endif
#endif

复制文件到jni目录并且实现该头文件

执行c文件编译

 ndk-build