[英]JNI build gradle fails on finding ndk directory
I set ndk.dir
in my local.properties
file. 我在
local.properties
文件中设置了ndk.dir
。 But, when grade
builds, this line 但是,当
grade
建立时,这条线
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
throws an error saying that android.ndkDirectory
is not set. 引发错误,指出未设置
android.ndkDirectory
。 How can I prevent myself to hard code the absolute path of ndkDirectory
? 如何防止自己对
ndkDirectory
的绝对路径进行硬编码?
This property has changed its name several times since NDK support was introduced. 自从引入NDK支持以来,此属性已多次更改名称 。 I am not sure it has stabilized now with the "experimental" plugin.
我不确定它现在是否已通过“实验性”插件稳定下来。
Therefore I would recommend a version independent approach, invented by Riccardo Ciovati in How do i read properties defined in local.properties in build.gradle : 因此,我建议由Riccardo Ciovati在如何读取build.gradle中的local.properties中定义的属性中发明的一种与版本无关的方法:
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.