对于刚刚接触NDK开发的朋友来说,可能会遇到这么一个问题:
新添加的cpp文件会提示:This file is not part of the project. Please include it in the appropriate build file (build.gradle, CMakeLists.txt or Android.mk etc) and sync the project.
对于出现的这个问题,不必惊慌,可以在CMakeLists.txt中修改如下配置:
file(GLOB native_srcs "src/main/jni/*.cpp") add_library( # Sets the name of the library. native-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). # Associated headers in the same location as their source # file are automatically included. ${native_srcs})再重新编译一下,就可以调用创建的cpp了