一、build.gradle 里面增加,指定jni Android.mk路径,当然也是可以指定CMakeLists.txt路径

    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
    externalNativeBuild {
        cmake {
            path 'src/main/jni/CMakeLists.txt'
        }
    }

二、官方介绍

android {
    externalNativeBuild {
        // Encapsulates your CMake build configurations.
        // For ndk-build, instead use the ndkBuild block.
        cmake {
            // Specifies a path to your CMake build script that's
            // relative to the build.gradle file.
            path "CMakeLists.txt"
        }
        
        ndkBuild {
		   path  	"Android.mk"
	   }
    }
}

	
cmake
Per module settings, such as the path to CMakeLists.txt, for an external CMake project.

MutableMap<String, Any>	
experimentalProperties
Additional per module experimental properties for C and C++.

	
ndkBuild
Per module settings, such as the path to Android.mk, for an external ndk-build project.

三、编译apk的时候也会把jin的内容编译进去。

四、参考文章

ExternalNativeBuild——安卓gradle-CSDN博客

ExternalNativeBuild  |  Android Developers

更多推荐