Skip to content

Commit e96182e

Browse files
Merge pull request #903 from NativeScript/vladimirov/improve-warning-range
Improve android tools warnings
2 parents 477b272 + 3486129 commit e96182e

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

lib/android-tools-info.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
3030
infoData.compileSdkVersion = this.getCompileSdk().wait();
3131
infoData.buildToolsVersion = this.getBuildToolsVersion().wait();
3232
infoData.targetSdkVersion = this.getTargetSdk().wait();
33-
infoData.supportLibraryVersion = this.getAndroidSupportLibVersion().wait();
33+
infoData.supportRepositoryVersion = this.getAndroidSupportRepositoryVersion().wait();
3434

3535
this.toolsInfo = infoData;
3636
}
@@ -54,13 +54,22 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
5454
}
5555

5656
if(!toolsInfoData.buildToolsVersion) {
57-
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()}'.`,
57+
let buildToolsRange = this.getBuildToolsRange();
58+
let versionRangeMatches = buildToolsRange.match(/^.*?([\d\.]+)\s+.*?([\d\.]+)$/);
59+
let message = `You can install any version in the following range: '${buildToolsRange}'.`;
60+
61+
// Improve message in case buildToolsRange is something like: ">=22.0.0 <=22.0.0" - same numbers on both sides
62+
if(versionRangeMatches && versionRangeMatches[1] && versionRangeMatches[2] && versionRangeMatches[1] === versionRangeMatches[2]) {
63+
message = `You have to install version ${versionRangeMatches[1]}.`;
64+
}
65+
66+
this.printMessage("You need to have the Android SDK Build-tools installed on your system. " + message,
5867
'Run "android" from your command-line to install required Android Build Tools.');
5968
}
6069

61-
if(!toolsInfoData.supportLibraryVersion) {
62-
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}}.`,
63-
'Run `$ android` to manage the Android Support Library.');
70+
if(!toolsInfoData.supportRepositoryVersion) {
71+
this.printMessage(`You need to have the latest Android Support Repository installed on your system.`,
72+
'Run `$ android` to manage the Android Support Repository.');
6473
}
6574

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

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

172-
private getAndroidSupportLibVersion(): IFuture<string> {
181+
private getAndroidSupportRepositoryVersion(): IFuture<string> {
173182
return ((): string => {
174183
let selectedAppCompatVersion: string;
175184
let requiredAppCompatRange = this.getAppCompatRange().wait();

lib/declarations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ interface IAndroidToolsInfoData {
130130
compileSdkVersion: number;
131131

132132
/**
133-
* The latest installed version of Android Support Library that satisfies CLI's requirements.
133+
* The latest installed version of Android Support Repository that satisfies CLI's requirements.
134134
*/
135-
supportLibraryVersion: string;
135+
supportRepositoryVersion: string;
136136

137137
/**
138138
* The Android targetSdkVersion specified by the user.

lib/services/android-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
176176
let compileSdk = androidToolsInfo.compileSdkVersion;
177177
let targetSdk = this.getTargetFromAndroidManifest().wait() || compileSdk;
178178
let buildToolsVersion = androidToolsInfo.buildToolsVersion;
179-
let appCompatVersion = androidToolsInfo.supportLibraryVersion;
179+
let appCompatVersion = androidToolsInfo.supportRepositoryVersion;
180180
let buildOptions = ["buildapk",
181181
`-PcompileSdk=android-${compileSdk}`,
182182
`-PtargetSdk=${targetSdk}`,

0 commit comments

Comments
 (0)