如何使用Gradle构建脚本自动构建第三方库?

时间:2019-07-04 05:52:06

标签: android gradle android-gradle build.gradle

我想自动构建jansson C库。我如何告诉gradle自动执行此操作。

通常,手动命令对于编译和安装第三方本机库是必需的。是否可以自动编译并安装?

1 个答案:

答案 0 :(得分:0)

jansson具有CMakeLists.txt;配置您的app / build.gradle以构建您的本机代码。

android {
  ...
  defaultConfig {...}
  buildTypes {...}

  // Encapsulates your external native build configurations.
  externalNativeBuild {

    // Encapsulates your CMake build configurations.
    cmake {

      // Provides a relative path to your CMake build script.
      path "CMakeLists.txt"
    }
  }
}

https://developer.android.com/studio/projects/gradle-external-native-builds.html#configure-gradle