From 5c8a8e83aca62cc5e3bb49eedae6fdf226b8cd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 14 Apr 2020 17:18:14 +0200 Subject: [PATCH] show proper error if nkd-build is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- android/app/build.gradle | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 7961ec95b9..4ef356b7ce 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -313,22 +313,34 @@ dependencies { implementation 'com.facebook.fresco:animated-gif:2.0.0' } -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use - -task hemroidBuild(type: Exec) { +def getLocalNDKDir = { -> def rootDir = project.rootDir def localProperties = new File(rootDir, "local.properties") - - def ndkDir = System.env.ANDROID_NDK - if (localProperties.exists()) { - Properties properties = new Properties() - localProperties.withInputStream { instr -> - properties.load(instr) - } - ndkDir = properties.getProperty('ndk.dir') + if (!localProperties.exists()) { + return null } - executable "$ndkDir/ndk-build" + Properties properties = new Properties() + localProperties.withInputStream { instr -> + properties.load(instr) + } + return properties.getProperty('ndk.dir') +} + +// Run this once to be able to run the application with BUCK +// puts all compile dependencies into folder libs for BUCK to use +task hemroidBuild(type: Exec) { + def localNdkDir = getLocalNDKDir() + def ndkDir = System.env.ANDROID_NDK + if (localNdkDir != null) { + ndkDir = localNdkDir + } + + def execPath = "$ndkDir/ndk-build" + def exec = new File(execPath) + if (!exec.exists()) { + throw new GradleException("No ndk-build binary found!") + } + executable execPath } preBuild.dependsOn hemroidBuild