一、第一步
在src/main/目录下新建一个JNI文件夹
二、第二步
在jni文件里面添加一个Android.mk文件以及第三方so库及其头文件:
三、编写Android.mk,源码如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := T613_I2C_DLL
LOCAL_SRC_FILES := Source/SharedLibs/$(TARGET_ARCH_ABI)/libT613_I2C_DLL.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := SerialPort
LOCAL_SRC_FILES := Source/SharedLibs/$(TARGET_ARCH_ABI)/libSerialPort.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/Source/include
LOCAL_MODULE := T613_FPC
LOCAL_SRC_FILES := JNI.cpp
LOCAL_SHARED_LIBRARIES := T613_I2C_DLL SerialPort
include $(BUILD_SHARED_LIBRARY)
四、配置一下app目录下的build.gradle文件,如下图所示