Skip to content

Commit 07bf7b1

Browse files
committed
fix: runtime supports sdk 28 only and user has 29 or no sdk, doctor prints wrong message
1 parent 065325f commit 07bf7b1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/android-tools-info.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
6969
const errors: NativeScriptDoctor.IWarning[] = [];
7070
const toolsInfoData = this.getToolsInfo(config);
7171
const isAndroidHomeValid = this.isAndroidHomeValid();
72+
const runtimeVersion = this.getRuntimeVersion(config);
73+
const supportsOnlyMinRequiredCompileTarget = this.getMaxSupportedCompileVersion(runtimeVersion) === AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET;
7274
if (!toolsInfoData.compileSdkVersion) {
7375
errors.push({
74-
warning: `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.`,
76+
warning: `Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK ${AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET}${supportsOnlyMinRequiredCompileTarget ? "" : " or later"}.`,
7577
additionalInformation: `Run \`\$ ${this.getPathToSdkManagementTool()}\` to manage your Android SDK versions.`,
7678
platforms: [Constants.ANDROID_PLATFORM_NAME]
7779
});
@@ -398,4 +400,12 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
398400

399401
return runtimeVersion;
400402
}
403+
404+
private getMaxSupportedCompileVersion(runtimeVersion: string): number {
405+
if (runtimeVersion && semver.lt(semver.coerce(runtimeVersion), "6.1.0")) {
406+
return 28;
407+
}
408+
409+
return this.parseAndroidSdkString(_.last(this.getSupportedTargets(runtimeVersion).sort()));
410+
}
401411
}

0 commit comments

Comments
 (0)