diff --git a/android/cli/commands/_buildModule.js b/android/cli/commands/_buildModule.js index 52e1ea70cbd..86302e1a8e4 100644 --- a/android/cli/commands/_buildModule.js +++ b/android/cli/commands/_buildModule.js @@ -206,11 +206,6 @@ AndroidModuleBuilder.prototype.validate = function validate(logger, config, cli) androidDetect(config, { packageJson: this.packageJson }, function (androidInfo) { this.androidInfo = androidInfo; - if (!this.androidInfo.ndk) { - logger.error(__('Unable to find a suitable installed Android NDK.') + '\n'); - process.exit(1); - } - const targetSDKMap = { // placeholder for gradle to use @@ -514,7 +509,8 @@ AndroidModuleBuilder.prototype.generateRootProjectFiles = async function generat await gradlew.writeGradlePropertiesFile(gradleProperties); // Create a "local.properties" file providing a path to the Android SDK/NDK directories. - await gradlew.writeLocalPropertiesFile(this.androidInfo.sdk.path, this.androidInfo.ndk.path); + const androidNdkPath = this.androidInfo.ndk ? this.androidInfo.ndk.path : null; + await gradlew.writeLocalPropertiesFile(this.androidInfo.sdk.path, androidNdkPath); // Copy our root "build.gradle" template script to the root build directory. const templatesDir = path.join(this.platformPath, 'templates', 'build'); diff --git a/build/lib/android/index.js b/build/lib/android/index.js index c919e833be6..c9d53707bf3 100644 --- a/build/lib/android/index.js +++ b/build/lib/android/index.js @@ -282,23 +282,17 @@ async function createLocalPropertiesFile(sdkPath, ndkPath) { } } } - if (!ndkPath) { - const message = 'Failed to find Android NDK directory path.'; - if (await fs.exists(filePath)) { - console.warn(`Warning: ${message} Will use last generated "${fileName}" file.`); - return; - } else { - throw new Error(message); - } - } // Create a "local.properties" file under Titanium's root "android" directory. // This is required by the Android gradle plugin or else it will fail to build. - const fileContentString - = '# This file was generated by Titanium\'s build tools.\n' - + 'sdk.dir=' + sdkPath.replace(/\\/g, '\\\\') + '\n' - + 'ndk.dir=' + ndkPath.replace(/\\/g, '\\\\') + '\n'; - await fs.writeFile(filePath, fileContentString); + const fileLines = [ + '# This file was generated by Titanium\'s build tools.', + 'sdk.dir=' + sdkPath.replace(/\\/g, '\\\\') + ]; + if (ndkPath) { + fileLines.push('ndk.dir=' + ndkPath.replace(/\\/g, '\\\\')); + } + await fs.writeFile(filePath, fileLines.join('\n') + '\n'); } function versionStringSortComparer(element1, element2) {