From 3486129f05232ed124abecea4cc69fe51cedf903 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Fri, 11 Sep 2015 09:00:53 +0300 Subject: [PATCH] Improve android tools warnings * Fix incorrect message for selected target SDK (Bulgarian symbols were used) * Improve message for build tools when the prefix and suffix have the same version (>=22 <=22) - https://github.com/NativeScript/nativescript-cli/issues/900 * Rename supportLibraryVersion to supportRepositoryVersion and improve messaging as Gradle does not work with Android Support Library - instead it works with Android Support Repository. --- lib/android-tools-info.ts | 23 ++++++++++++++++------- lib/declarations.ts | 4 ++-- lib/services/android-project-service.ts | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/android-tools-info.ts b/lib/android-tools-info.ts index 2188279e44..773a207307 100644 --- a/lib/android-tools-info.ts +++ b/lib/android-tools-info.ts @@ -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; } @@ -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) { @@ -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.`); } @@ -169,7 +178,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { }).future()(); } - private getAndroidSupportLibVersion(): IFuture { + private getAndroidSupportRepositoryVersion(): IFuture { return ((): string => { let selectedAppCompatVersion: string; let requiredAppCompatRange = this.getAppCompatRange().wait(); diff --git a/lib/declarations.ts b/lib/declarations.ts index 24d80d3dba..26febe1e6d 100644 --- a/lib/declarations.ts +++ b/lib/declarations.ts @@ -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. diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index 8416118a39..6732b6c369 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -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}`,