- Start a new native c++ project in android studio 4.1.1.
- Go to
build.gradleof the module - Add a
targetsline:
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
targets "native-lib" // New line
}
}
Somehow I get an error when I click the green play button (Run 'app'):
Build file '<project folder>/app/build.gradle' line: 5
A problem occurred evaluating project ':app'.
> No signature of method: build_bcdq4hni531na6stswx8a7txx.android() is
applicable for argument types: (build_bcdq4hni531na6stswx8a7txx$_run_closure1)
values: [build_bcdq4hni531na6stswx8a7txx$_run_closure1@41fd5f78]
What is going on?
The targets property is documented at: https://developer.android.com/studio/projects/gradle-external-native-builds
The answer to this question also use the targets property.
Disabling a CMake target when building Android app
I can't even pass an argument to CMake by adding arguments "-DOPTION=1" to build.gradle!