Stay organized with collections
Save and categorize content based on your preferences.
ExternalNativeBuild
interface ExternalNativeBuild
DSL object to configure external native builds using CMake or ndk-build
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"
}
}
}
To learn more about including external native builds to your Android Studio projects, read Add C and C++ Code to Your Project
Summary
Public functions |
Unit |
Per module settings, such as the path to CMakeLists.txt , for an external CMake project.
|
Unit |
Per module settings, such as the path to Android.mk , for an external ndk-build project.
|
Public properties |
Cmake |
Per module settings, such as the path to CMakeLists.txt , for an external CMake project.
|
MutableMap<String, Any> |
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.
|
Public functions
cmake
fun cmake(action: @ExtensionFunctionType Cmake.() -> Unit): Unit
Per module settings, such as the path to CMakeLists.txt
, for an external CMake project.
For more information about the properties you can configure in this block, see Cmake
.
Public properties
cmake
val cmake: Cmake
Per module settings, such as the path to CMakeLists.txt
, for an external CMake project.
For more information about the properties you can configure in this block, see Cmake
.
ndkBuild
val ndkBuild: NdkBuild
Per module settings, such as the path to Android.mk
, for an external ndk-build project.
For more information about the properties you can configure in this block, see NdkBuild
.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ExternalNativeBuild\n===================\n\n\n```\ninterface ExternalNativeBuild\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nDSL object to configure external native builds using [CMake](https://cmake.org/) or [ndk-build](https://developer.android.com/ndk/guides/build.html) \n\n```text\nandroid {\n externalNativeBuild {\n // Encapsulates your CMake build configurations.\n // For ndk-build, instead use the ndkBuild block.\n cmake {\n // Specifies a path to your CMake build script that's\n // relative to the build.gradle file.\n path \"CMakeLists.txt\"\n }\n }\n}\n```\n\nTo learn more about including external native builds to your Android Studio projects, read [Add C and C++ Code to Your Project](https://developer.android.com/studio/projects/add-native-code.html)\n\nSummary\n-------\n\n| ### Public functions ||\n|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [cmake](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/ExternalNativeBuild#cmake(kotlin.Function1))`(action: @`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` `[Cmake](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/Cmake)`.() `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Per module settings, such as the path to `CMakeLists.txt`, for an external CMake project. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [ndkBuild](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/ExternalNativeBuild#ndkBuild(kotlin.Function1))`(action: @`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` `[NdkBuild](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/NdkBuild)`.() `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Per module settings, such as the path to `Android.mk`, for an external ndk-build project. |\n\n| ### Public properties ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Cmake](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/Cmake) | [cmake](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/ExternalNativeBuild#cmake()) Per module settings, such as the path to `CMakeLists.txt`, for an external CMake project. |\n| [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`\u003c`[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`\u003e` | [experimentalProperties](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/ExternalNativeBuild#experimentalProperties()) Additional per module experimental properties for C and C++. |\n| [NdkBuild](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/NdkBuild) | [ndkBuild](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/ExternalNativeBuild#ndkBuild()) Per module settings, such as the path to `Android.mk`, for an external ndk-build project. |\n\nPublic functions\n----------------\n\n### cmake\n\n```\nfun cmake(action: @ExtensionFunctionType Cmake.() -\u003e Unit): Unit\n```\n\nPer module settings, such as the path to `CMakeLists.txt`, for an external CMake project.\n\nFor more information about the properties you can configure in this block, see [Cmake](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/Cmake). \n\n### ndkBuild\n\n```\nfun ndkBuild(action: @ExtensionFunctionType NdkBuild.() -\u003e Unit): Unit\n```\n\nPer module settings, such as the path to `Android.mk`, for an external ndk-build project.\n\nFor more information about the properties you can configure in this block, see [NdkBuild](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/NdkBuild).\n\nPublic properties\n-----------------\n\n### cmake\n\n```\nval cmake: Cmake\n```\n\nPer module settings, such as the path to `CMakeLists.txt`, for an external CMake project.\n\nFor more information about the properties you can configure in this block, see [Cmake](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/Cmake). \n\n### experimentalProperties\n\n```\nval experimentalProperties: MutableMap\u003cString, Any\u003e\n```\n\nAdditional per module experimental properties for C and C++. \n\n### ndkBuild\n\n```\nval ndkBuild: NdkBuild\n```\n\nPer module settings, such as the path to `Android.mk`, for an external ndk-build project.\n\nFor more information about the properties you can configure in this block, see [NdkBuild](/reference/tools/gradle-api/8.0/com/android/build/api/dsl/NdkBuild)."]]