Skip to content

Commit 5e7ba5a

Browse files
Add check for JAVA 9
Currently Gradle cannot work with JAVA 9, so detect if it has been used and break the build for Android. Also the check will print warning when `tns doctor` is called. Also update submodule, where the following change is applied: Fix detection of Javac version The command `javac -version` prints result to stderr when JAVA 8 is used and to stdout when JAVA 9 is used. Current check in CLI uses the stderr output, so when JAVA 9 is installed it fails to detect the correct version. In order to support both JAVA 8 and JAVA 9, capture both stdout and stderr and get the version from there. Also remove unneeded check for Java version - we care about JAVA Compiler, which is included in JDK.
1 parent e705483 commit 5e7ba5a

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/android-tools-info.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
1010
private static REQUIRED_BUILD_TOOLS_RANGE_PREFIX = ">=23";
1111
private static VERSION_REGEX = /((\d+\.){2}\d+)/;
1212
private static MIN_JAVA_VERSION = "1.8.0";
13+
private static MAX_JAVA_VERSION = "1.9.0";
1314

1415
private showWarningsAsErrors: boolean;
1516
private toolsInfo: IAndroidToolsInfoData;
@@ -111,10 +112,14 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
111112
+ "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 +
112113
" described in " + this.$staticConfig.SYS_REQUIREMENTS_LINK;
113114
const matchingVersion = (installedJavaVersion || "").match(AndroidToolsInfo.VERSION_REGEX);
114-
if (matchingVersion && matchingVersion[1]) {
115-
if (semver.lt(matchingVersion[1], AndroidToolsInfo.MIN_JAVA_VERSION)) {
115+
const installedJavaCompilerVersion = matchingVersion && matchingVersion[1];
116+
if (installedJavaCompilerVersion) {
117+
if (semver.lt(installedJavaCompilerVersion, AndroidToolsInfo.MIN_JAVA_VERSION)) {
116118
hasProblemWithJavaVersion = true;
117119
this.printMessage(`Javac version ${installedJavaVersion} is not supported. You have to install at least ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage);
120+
} else if (semver.gt(installedJavaCompilerVersion, AndroidToolsInfo.MAX_JAVA_VERSION)) {
121+
hasProblemWithJavaVersion = true;
122+
this.printMessage(`Javac version ${installedJavaVersion} is not supported. You have to install version ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage);
118123
}
119124
} else {
120125
hasProblemWithJavaVersion = true;

lib/services/doctor-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ class DoctorService implements IDoctorService {
104104
}
105105

106106
const androidToolsIssues = this.$androidToolsInfo.validateInfo();
107-
const javaVersionIssue = await this.$androidToolsInfo.validateJavacVersion(sysInfo.javacVersion);
107+
const javaCompilerVersionIssue = await this.$androidToolsInfo.validateJavacVersion(sysInfo.javacVersion);
108108
const pythonIssues = await this.validatePythonPackages();
109-
const doctorResult = result || androidToolsIssues || javaVersionIssue || pythonIssues;
109+
const doctorResult = result || androidToolsIssues || javaCompilerVersionIssue || pythonIssues;
110110

111111
if (!configOptions || configOptions.trackResult) {
112112
await this.$analyticsService.track("DoctorEnvironmentSetup", doctorResult ? "incorrect" : "correct");

0 commit comments

Comments
 (0)