Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android)(9_0_X): build should auto-download NDK if not installed #11532

Merged
merged 3 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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