diff --git a/src/debugger/cordovaDebugSession.ts b/src/debugger/cordovaDebugSession.ts index b008957..e4b753b 100644 --- a/src/debugger/cordovaDebugSession.ts +++ b/src/debugger/cordovaDebugSession.ts @@ -186,6 +186,14 @@ export default class CordovaDebugSession extends LoggingDebugSession { } await this.initializeTelemetry(launchArgs.cwd); await this.initializeSettings(launchArgs); + + if (launchArgs.platform == "android") { + const versionInfo = CordovaProjectHelper.checkCordovaAndroidVersion(launchArgs.cwd); + if (versionInfo != "") { + this.outputLogger(versionInfo); + } + } + this.platform = await this.resolvePlatform(launchArgs); if (this.platform instanceof AbstractMobilePlatform) { diff --git a/src/utils/cordovaProjectHelper.ts b/src/utils/cordovaProjectHelper.ts index 390062d..b27f719 100644 --- a/src/utils/cordovaProjectHelper.ts +++ b/src/utils/cordovaProjectHelper.ts @@ -598,4 +598,38 @@ export class CordovaProjectHelper { ).name; return packageName; } + + private static getCordovaAndroidVersionMessage( + mainVersion: string, + sdkVersion: string, + buildToolVersion: string, + ): string { + return `Your cordova-android version is ${mainVersion}, reqiured target sdk ${sdkVersion} and build-tools ${buildToolVersion}.`; + } + + public static checkCordovaAndroidVersion(projectRoot: string): string { + let androidVersion; + try { + const devDeps = JSON.parse( + fs.readFileSync(findFileInFolderHierarchy(projectRoot, "package.json"), "utf-8"), + ).devDependencies; + androidVersion = devDeps["cordova-android"].replace("^", ""); + } catch { + return ""; + } + + if (androidVersion != "") { + const mainVersion = androidVersion.split(".")[0]; + switch (mainVersion) { + case "12": + return this.getCordovaAndroidVersionMessage("12", "33", "33.0.2"); + case "11": + return this.getCordovaAndroidVersionMessage("11", "32", "32.0.0"); + case "10": + return this.getCordovaAndroidVersionMessage("10", "30", "30.0.3"); + default: + return ""; + } + } + } }