在build.gradle文件的externalNativeBuild中指定目标->没有方法签名 [英] Specify targets in externalNativeBuild of the build.gradle file-> No signature of method
问题描述
- 在android studio 4.1.1中启动一个新的本机c ++项目.
- 转到模块的
build.gradle
- 添加
targets
行:
- Start a new native c++ project in android studio 4.1.1.
- Go to
build.gradle
of the module - Add a
targets
line:
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]
这是怎么回事?
targets
属性记录在: https://developer.android.com/studio/projects/gradle-external-native-builds
此问题的答案也使用targets
属性.
在构建Android应用时禁用CMake目标
The answer to this question also use the targets
property.
Disabling a CMake target when building Android app
我什至不能通过将arguments "-DOPTION=1"
添加到build.gradle
来将参数传递给CMake!
I can't even pass an argument to CMake by adding arguments "-DOPTION=1"
to build.gradle
!
推荐答案
也许目标"和其他选项将放置在android.defaultConfig.externalNativeBuild(而不是android.externalNativeBuild)中.
Maybe the "targets" and other options are to be placed in android.defaultConfig.externalNativeBuild (instead of android.externalNativeBuild).
android {
defaultConfig {
:
externalNativeBuild {
cmake {
targets "native-lib" // New line here!
}
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
// targets "native-lib" // Not here!
}
}
}
这篇关于在build.gradle文件的externalNativeBuild中指定目标->没有方法签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!