当前位置:   article > 正文

2024-01-03 android studio build.gradle使用 ExternalNativeBuild 设置Android.mk 在编译apk时候同时编译jni

externalnativebuild

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

  1. externalNativeBuild {
  2. ndkBuild {
  3. path 'src/main/jni/Android.mk'
  4. }
  5. }
  1. externalNativeBuild {
  2. cmake {
  3. path 'src/main/jni/CMakeLists.txt'
  4. }
  5. }

二、官方介绍

  1. android {
  2. externalNativeBuild {
  3. // Encapsulates your CMake build configurations.
  4. // For ndk-build, instead use the ndkBuild block.
  5. cmake {
  6. // Specifies a path to your CMake build script that's
  7. // relative to the build.gradle file.
  8. path "CMakeLists.txt"
  9. }
  10. ndkBuild {
  11. path "Android.mk"
  12. }
  13. }
  14. }
  15. cmake
  16. Per module settings, such as the path to CMakeLists.txt, for an external CMake project.
  17. MutableMap<String, Any>
  18. experimentalProperties
  19. Additional per module experimental properties for C and C++.
  20. ndkBuild
  21. Per module settings, such as the path to Android.mk, for an external ndk-build project.

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

四、参考文章

ExternalNativeBuild——安卓gradle-CSDN博客

ExternalNativeBuild  |  Android Developers

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/573140
推荐阅读
相关标签
  

闽ICP备14008679号