JNI构建gradle在找到ndk目录时失败

时间:2015-09-18 09:37:13

标签: java android android-ndk java-native-interface

我在ndk.dir文件中设置local.properties。但是,当grade构建时,此行

task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
        def ndkDir = android.ndkDirectory

抛出错误,指出未设置android.ndkDirectory。如何防止自己硬编码ndkDirectory的绝对路径?

1 个答案:

答案 0 :(得分:2)

自引入NDK支持以来,

此属性 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')