【问题标题】:JNI build gradle fails on finding ndk directoryJNI build gradle 找不到 ndk 目录
【发布时间】:2015-12-15 09:48:30
【问题描述】:

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

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

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

【问题讨论】:

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


    【解决方案1】:

    自从引入 NDK 支持以来,此属性 has changed its name 多次。我不确定它现在是否已通过“实验性”插件稳定下来。

    因此,我会推荐一种独立于版本的方法,由 Riccardo CiovatiHow do i read properties defined in local.properties in build.gradle 中发明:

    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ndkDir = properties.getProperty('ndk.dir')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-11
      • 1970-01-01
      • 1970-01-01
      • 2012-12-18
      • 1970-01-01
      • 2017-02-18
      相关资源
      最近更新 更多