在cpp文件夹下新建一个c/c++文件
java层的代码
给CMakeLists.txt配置加下面的代码
add_library( # Sets the name of the library. demo # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). src/main/cpp/demo.c) target_link_libraries( # Specifies the target library. demo # Links the target library to the log library # included in the NDK. ${log-lib} )
build.gradle里面一定要有这两个配置
c中的代码
运行测试