1

I set ndk.dir in my local.properties file. But, when grade builds, this line

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

throws an error saying that android.ndkDirectory is not set. How can I prevent myself to hard code the absolute path of ndkDirectory ?

user1611830
  • 4,749
  • 10
  • 52
  • 89

1 Answers1

4

This property has changed its name several times since NDK support was introduced. 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:

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307