Skip to content

Commit

Permalink
feat(android)(9_0_X): build should auto-download NDK if not installed (
Browse files Browse the repository at this point in the history
  • Loading branch information
jquick-axway committed Mar 20, 2020
1 parent d327f3c commit 6c1a206
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
8 changes: 2 additions & 6 deletions android/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down
22 changes: 8 additions & 14 deletions build/lib/android/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6c1a206

Please sign in to comment.