一、概述
这篇文章用于记录JNI开发入门第一步,通过AS进行编写JNI代码,并生成so库文件。
二、NDK环境搭建
AS中下载NDK
创建一个jni项目
AS会帮我们创建两个文件
三、编写JNI代码
打开CMakeLists.txt文件,可以看到生成so库的名称和连接的cpp文件等。
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.10.2)
# Declares and names the project.
project("myapplication")
# Creates and names a library, sets it as either STATIC
# or SHARED