1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
//////////////
// NDK Support
//////////////
// If using this, Android studio will fail run the following to set the environment variable for android studio:
// export ANDROID_NDK_HOME=/Android/android-ndk-r8e (Linux)
// launchctl setenv ANDROID_NDK_HOME /Android/android-ndk-r8e (Mac)
// or, better, add the export to the .profile of your user home and re-login
task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
// TODO fix deprecated
dependsOn 'buildNative'
from(new File('src/main/libs')) { include '**/*.so' }
into new File(buildDir, 'native-libs')
}
// TODO fix deprecated
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File(buildDir, 'native-libs')
}
task buildNative(type: Exec) {
if (System.env.ANDROID_NDK_HOME != null) {
def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
commandLine ndkBuild, "--directory", ".... I miss this part, hardcoding it works ...."
} else {
doLast {
println '##################'
println 'Skipping NDK build'
println 'Reason: ANDROID_NDK_HOME not set.'
println '##################'
}
}
} |
Partager