diff --git a/lib/android-tools-info.ts b/lib/android-tools-info.ts index 773a207307..a22d7ff4a9 100644 --- a/lib/android-tools-info.ts +++ b/lib/android-tools-info.ts @@ -39,8 +39,9 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { }).future()(); } - public validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture { - return (() => { + public validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture { + return (() : boolean => { + let detectedErrors = false; this.showWarningsAsErrors = options && options.showWarningsAsErrors; let toolsInfoData = this.getToolsInfo().wait(); if(!toolsInfoData.androidHomeEnvVar || !this.$fs.exists(toolsInfoData.androidHomeEnvVar).wait()) { @@ -51,6 +52,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { if(!toolsInfoData.compileSdkVersion) { this.printMessage(`Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK ${AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET} or later.`, "Run `$ android` to manage your Android SDK versions."); + detectedErrors = true; } if(!toolsInfoData.buildToolsVersion) { @@ -65,11 +67,13 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { 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.'); + detectedErrors = true; } 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.'); + detectedErrors = true; } if(options && options.validateTargetSdk) { @@ -81,12 +85,15 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { if(targetSdk && (targetSdk < minSupportedVersion)) { this.printMessage(`The selected Android target SDK ${newTarget} is not supported. You must target ${minSupportedVersion} or later.`); + detectedErrors = true; } 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.`); } } } - }).future()(); + + return detectedErrors; + }).future()(); } /** diff --git a/lib/declarations.ts b/lib/declarations.ts index 26febe1e6d..529e96c6c7 100644 --- a/lib/declarations.ts +++ b/lib/declarations.ts @@ -105,9 +105,9 @@ interface IAndroidToolsInfo { /** * Validates the information about required Android tools and SDK versions. * @param {any} options Defines if the warning messages should treated as error and if the targetSdk value should be validated as well. - * @return {void} + * @return {boolean} True if there are detected issues, false otherwise. */ - validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture; + validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture; } /** diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index dd12b92ca2..1f8aae0c70 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -69,12 +69,14 @@ class DoctorService implements IDoctorService { this.$logger.warn("WARNING: Gradle is not installed or is not configured properly."); this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL + "To be able to build for Android and run apps in the emulator or on a connected device, verify that you have installed Gradle."); + result = true; } if(sysInfo.gradleVer && helpers.versionCompare(sysInfo.gradleVer, DoctorService.MIN_SUPPORTED_GRADLE_VERSION) === -1) { this.$logger.warn(`WARNING: Gradle version is lower than ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION}.`); this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL + `To be able to build for Android and run apps in the emulator or on a connected device, verify thqt you have at least ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION} version installed.`); + result = true; } if(!sysInfo.javacVersion) { @@ -82,10 +84,11 @@ class DoctorService implements IDoctorService { this.$logger.out("You will not be able to build your projects for Android." + EOL + "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL + " described in https://github.com/NativeScript/nativescript-cli#system-requirements."); + result = true; } - this.$androidToolsInfo.validateInfo().wait(); - return result; + let androidToolsIssues = this.$androidToolsInfo.validateInfo().wait(); + return result || androidToolsIssues; } private printPackageManagerTip() {