build.gradle模块targets一行: externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
targets "native-lib" // New line
}
}
Run Code Online (Sandbox Code Playgroud)
不知何故,当我单击绿色播放按钮(运行“应用程序”)时出现错误:
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]
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?
该targets属性记录在:https : //developer.android.com/studio/projects/gradle-external-native-builds
这个问题的答案也使用targets属性。
在构建 Android 应用程序时禁用 CMake 目标
我什至不能通过添加arguments "-DOPTION=1"到CMake 来传递参数build.gradle!