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 methods
|
abstract 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.
|
abstract 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.
|
Properties
|
abstract 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.
|
abstract 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 methods
cmake
abstract fun cmake(action: 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
abstract fun ndkBuild(action: 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
Properties
cmake
abstract 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
abstract 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```\ninterface ExternalNativeBuild\n```\n\n|----------------------------------------------------|\n| [com.android.build.api.dsl.ExternalNativeBuild](#) |\n\nDSL object to configure external native builds using\n[CMake](https://cmake.org/)\nor\n[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\n[Add C and C++ Code to Your Project](https://developer.android.com/studio/projects/add-native-code.html)\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [cmake](#cmake(kotlin.Function1))`(`action:` `[Cmake](/reference/tools/gradle-api/7.1/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| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [ndkBuild](#ndkBuild(kotlin.Function1))`(`action:` `[NdkBuild](/reference/tools/gradle-api/7.1/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| ### Properties ||\n|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Cmake](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/Cmake) | [cmake](#cmake:com.android.build.api.dsl.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| abstract [NdkBuild](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/NdkBuild) | [ndkBuild](#ndkBuild:com.android.build.api.dsl.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 methods\n--------------\n\n### cmake\n\n```\nabstract fun cmake(action: Cmake.() -\u003e Unit): Unit\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path\nto 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.1/com/android/build/api/dsl/Cmake) \n\n### ndkBuild\n\n```\nabstract fun ndkBuild(action: NdkBuild.() -\u003e Unit): Unit\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path\nto 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.1/com/android/build/api/dsl/NdkBuild)\n\nProperties\n----------\n\n### cmake\n\n```\nabstract val cmake: Cmake\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path\nto 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.1/com/android/build/api/dsl/Cmake) \n\n### ndkBuild\n\n```\nabstract val ndkBuild: NdkBuild\n```\n\nEncapsulates per-variant configurations for your external ndk-build project, such as the path\nto your `Android.mk` build script and build output directory.\n\nFor more information about the properties you can configure in this block, see\n[NdkBuild](/reference/tools/gradle-api/7.1/com/android/build/api/dsl/NdkBuild)"]]