Skip to content

Commit d3707fe

Browse files
Fix check for Gradle version
In case Gradle's version is with three numbers ("2.2.3" for example), our current check is failing and makes the doctor command unusable. Compare current gradle version with min required one only after they are in the same format.
1 parent 138a834 commit d3707fe

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/common

Submodule common updated 1 file

lib/services/doctor-service.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DoctorService implements IDoctorService {
6666
result = true;
6767
}
6868

69-
if(sysInfo.gradleVer && helpers.versionCompare(sysInfo.gradleVer, DoctorService.MIN_SUPPORTED_GRADLE_VERSION) === -1) {
69+
if(sysInfo.gradleVer && !this.isGradleVersionSupported(sysInfo.gradleVer)) {
7070
this.$logger.warn(`WARNING: Gradle version is lower than ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION}.`);
7171
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
7272
+ `To be able to build for Android and run apps in the emulator or on a connected device, verify that you have at least ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION} version installed.`);
@@ -106,5 +106,14 @@ class DoctorService implements IDoctorService {
106106
this.$logger.out("TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies." + EOL);
107107
}
108108
}
109+
110+
private isGradleVersionSupported(gradleVersion: string): boolean {
111+
let minSupportedVersion = DoctorService.MIN_SUPPORTED_GRADLE_VERSION;
112+
let requiredLength = _.max([gradleVersion.split(".").length, minSupportedVersion.split(".").length]);
113+
gradleVersion = helpers.appendZeroesToVersion(gradleVersion, requiredLength);
114+
minSupportedVersion = helpers.appendZeroesToVersion(minSupportedVersion, requiredLength);
115+
116+
return helpers.versionCompare(gradleVersion, minSupportedVersion) !== -1;
117+
}
109118
}
110119
$injector.register("doctorService", DoctorService);

0 commit comments

Comments
 (0)