Reputation: 4857
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
?
Upvotes: 1
Views: 3859
Reputation: 57173
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')
Upvotes: 4