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 |
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your CMakeLists.txt build script and build output directory.
|
Unit |
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your Android.mk build script and build output directory.
|
Public properties |
Cmake |
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your CMakeLists.txt build script and build output directory.
|
NdkBuild |
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your Android.mk build script and build output directory.
|
Public functions
cmake
fun cmake(action: (@ExtensionFunctionType Cmake.() -> Unit)?): Unit
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your CMakeLists.txt
build script and build output directory.
For more information about the properties you can configure in this block, see Cmake
ndkBuild
fun ndkBuild(action: (@ExtensionFunctionType NdkBuild.() -> Unit)?): Unit
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your Android.mk
build script and build output directory.
For more information about the properties you can configure in this block, see NdkBuild
Public properties
cmake
val cmake: Cmake
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your CMakeLists.txt
build script and build output directory.
For more information about the properties you can configure in this block, see Cmake
ndkBuild
val ndkBuild: NdkBuild
Encapsulates per-variant configurations for your external ndk-build project, such as the path to your Android.mk
build script and build output directory.
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/7.2/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/7.2/com/android/build/api/dsl/Cmake)`.() `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)?)` Encapsulates per-variant configurations for your external ndk-build project, such as the path to your `CMakeLists.txt` build script and build output directory. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [ndkBuild](/reference/tools/gradle-api/7.2/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/7.2/com/android/build/api/dsl/NdkBuild)`.() `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)?)` Encapsulates per-variant configurations for your external ndk-build project, such as the path to your `Android.mk` build script and build output directory. |\n\n| ### Public properties ||\n|--------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Cmake](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/Cmake) | [cmake](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ExternalNativeBuild#cmake()) Encapsulates per-variant configurations for your external ndk-build project, such as the path to your `CMakeLists.txt` build script and build output directory. |\n| [NdkBuild](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/NdkBuild) | [ndkBuild](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ExternalNativeBuild#ndkBuild()) Encapsulates per-variant configurations for your external ndk-build project, such as the path to your `Android.mk` build script and build output directory. |\n\nPublic functions\n----------------\n\n### cmake\n\n```\nfun cmake(action: (@ExtensionFunctionType Cmake.() -\u003e Unit)?): Unit\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path to your `CMakeLists.txt` build script and build output directory.\n\nFor more information about the properties you can configure in this block, see [Cmake](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/Cmake) \n\n### ndkBuild\n\n```\nfun ndkBuild(action: (@ExtensionFunctionType NdkBuild.() -\u003e Unit)?): Unit\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path to your `Android.mk` build script and build output directory.\n\nFor more information about the properties you can configure in this block, see [NdkBuild](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/NdkBuild)\n\nPublic properties\n-----------------\n\n### cmake\n\n```\nval cmake: Cmake\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path to your `CMakeLists.txt` build script and build output directory.\n\nFor more information about the properties you can configure in this block, see [Cmake](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/Cmake) \n\n### ndkBuild\n\n```\nval ndkBuild: NdkBuild\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path to your `Android.mk` build script and build output directory.\n\nFor more information about the properties you can configure in this block, see [NdkBuild](/reference/tools/gradle-api/7.2/com/android/build/api/dsl/NdkBuild)"]]