我在ndk.dir
文件中设置local.properties
。但是,当grade
构建时,此行
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
抛出错误,指出未设置android.ndkDirectory
。如何防止自己硬编码ndkDirectory
的绝对路径?
答案 0 :(得分:2)
此属性 has changed its name 多次。我不确定它现在已经稳定了"实验"插件。
因此,我建议采用Riccardo Ciovati How do i read properties defined in local.properties in build.gradle 中tymeJV发明的版本无关方法:
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')