Skip to content

Improve android tools warnings #903

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

Merged
merged 1 commit into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions lib/android-tools-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
infoData.compileSdkVersion = this.getCompileSdk().wait();
infoData.buildToolsVersion = this.getBuildToolsVersion().wait();
infoData.targetSdkVersion = this.getTargetSdk().wait();
infoData.supportLibraryVersion = this.getAndroidSupportLibVersion().wait();
infoData.supportRepositoryVersion = this.getAndroidSupportRepositoryVersion().wait();

this.toolsInfo = infoData;
}
Expand All @@ -54,13 +54,22 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
}

if(!toolsInfoData.buildToolsVersion) {
this.printMessage(`You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '${this.getBuildToolsRange()}'.`,
let buildToolsRange = this.getBuildToolsRange();
let versionRangeMatches = buildToolsRange.match(/^.*?([\d\.]+)\s+.*?([\d\.]+)$/);
let message = `You can install any version in the following range: '${buildToolsRange}'.`;

// Improve message in case buildToolsRange is something like: ">=22.0.0 <=22.0.0" - same numbers on both sides
if(versionRangeMatches && versionRangeMatches[1] && versionRangeMatches[2] && versionRangeMatches[1] === versionRangeMatches[2]) {
message = `You have to install version ${versionRangeMatches[1]}.`;
}

this.printMessage("You need to have the Android SDK Build-tools installed on your system. " + message,
'Run "android" from your command-line to install required Android Build Tools.');
}

if(!toolsInfoData.supportLibraryVersion) {
this.printMessage(`You need to have the Android Support Library installed on your system. You can install any version in the following range: ${this.getAppCompatRange().wait() || ">=" + AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET}}.`,
'Run `$ android` to manage the Android Support Library.');
if(!toolsInfoData.supportRepositoryVersion) {
this.printMessage(`You need to have the latest Android Support Repository installed on your system.`,
'Run `$ android` to manage the Android Support Repository.');
}

if(options && options.validateTargetSdk) {
Expand All @@ -71,7 +80,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
let minSupportedVersion = this.parseAndroidSdkString(_.first(supportedVersions));

if(targetSdk && (targetSdk < minSupportedVersion)) {
this.printMessage(`The selected Android target SDK ${newTarget} is not supported. You пкяш target ${minSupportedVersion} or later.`);
this.printMessage(`The selected Android target SDK ${newTarget} is not supported. You must target ${minSupportedVersion} or later.`);
} else if(!targetSdk || targetSdk > this.getMaxSupportedVersion()) {
this.$logger.warn(`Support for the selected Android target SDK ${newTarget} is not verified. Your Android app might not work as expected.`);
}
Expand Down Expand Up @@ -169,7 +178,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
}).future<string>()();
}

private getAndroidSupportLibVersion(): IFuture<string> {
private getAndroidSupportRepositoryVersion(): IFuture<string> {
return ((): string => {
let selectedAppCompatVersion: string;
let requiredAppCompatRange = this.getAppCompatRange().wait();
Expand Down
4 changes: 2 additions & 2 deletions lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ interface IAndroidToolsInfoData {
compileSdkVersion: number;

/**
* The latest installed version of Android Support Library that satisfies CLI's requirements.
* The latest installed version of Android Support Repository that satisfies CLI's requirements.
*/
supportLibraryVersion: string;
supportRepositoryVersion: string;

/**
* The Android targetSdkVersion specified by the user.
Expand Down
2 changes: 1 addition & 1 deletion lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
let compileSdk = androidToolsInfo.compileSdkVersion;
let targetSdk = this.getTargetFromAndroidManifest().wait() || compileSdk;
let buildToolsVersion = androidToolsInfo.buildToolsVersion;
let appCompatVersion = androidToolsInfo.supportLibraryVersion;
let appCompatVersion = androidToolsInfo.supportRepositoryVersion;
let buildOptions = ["buildapk",
`-PcompileSdk=android-${compileSdk}`,
`-PtargetSdk=${targetSdk}`,
Expand Down