A newly created Ionic project does not build for android

I just created a new Ionic Project with blank template. After I have added android platform to that project and tried the following command.

ionic cordova build android

I get the following error


ng.cmd run app:ionic-cordova-build --platform=android
An unhandled exception occurred: Project target does not exist.
See “C:\Users\x~1\AppData\Local\Temp\ng-vh8aNb\angular-errors.log” for further details.
[ERROR] An error occurred while running subprocess ng.


Below is my ionic info

C:\x\ionic6\sampleapp>ionic info

Ionic:

Ionic CLI : 5.4.16 (C:\Users\x\AppData\Roaming\nvm\v16.14.2\node_modules\ionic)
Ionic Framework : @ionic/angular 6.0.12
@angular-devkit/build-angular : 13.2.6
@angular-devkit/schematics : 13.2.6
@angular/cli : 13.2.6
@ionic/angular-toolkit : 6.1.0

Cordova:

Cordova CLI : 11.0.0
Cordova Platforms : android 10.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 3 other plugins)

Utility:

cordova-res : 0.15.4
native-run : not installed

System:

Android SDK Tools : 26.1.1 (C:\Users\x\AppData\Local\Android\Sdk)
NodeJS : v16.14.2 (C:\Program Files\nodejs\node.exe)
npm : 8.5.0
OS : Windows 10

I am using NVM for windows in my environment. Any help in resolving the above issue would be highly appreciated

Here is my Package.json

{
“name”: “sampleapp”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “https://ionicframework.com/”,
“scripts”: {
“ng”: “ng”,
“start”: “ng serve”,
“build”: “ng build”,
“test”: “ng test”,
“lint”: “ng lint”,
“e2e”: “ng e2e”
},
“private”: true,
“dependencies”: {
@angular/common”: “~13.2.2”,
@angular/core”: “~13.2.2”,
@angular/forms”: “~13.2.2”,
@angular/platform-browser”: “~13.2.2”,
@angular/platform-browser-dynamic”: “~13.2.2”,
@angular/router”: “~13.2.2”,
@ionic/angular”: “^6.0.0”,
“cordova-android”: “10.1.1”,
“rxjs”: “~6.6.0”,
“tslib”: “^2.2.0”,
“zone.js”: “~0.11.4”
},
“devDependencies”: {
@angular-devkit/build-angular”: “~13.2.3”,
@angular-eslint/builder”: “~13.0.1”,
@angular-eslint/eslint-plugin”: “~13.0.1”,
@angular-eslint/eslint-plugin-template”: “~13.0.1”,
@angular-eslint/template-parser”: “~13.0.1”,
@angular/cli”: “~13.2.3”,
@angular/compiler”: “~13.2.2”,
@angular/compiler-cli”: “~13.2.2”,
@angular/language-service”: “~13.2.2”,
@ionic/angular-toolkit”: “^6.0.0”,
@types/jasmine”: “~3.6.0”,
@types/jasminewd2”: “~2.0.3”,
@types/node”: “^12.11.1”,
@typescript-eslint/eslint-plugin”: “5.3.0”,
@typescript-eslint/parser”: “5.3.0”,
“cordova-plugin-device”: “2.0.2”,
“cordova-plugin-ionic-keyboard”: “^2.0.5”,
“cordova-plugin-ionic-webview”: “^5.0.0”,
“cordova-plugin-splashscreen”: “5.0.2”,
“cordova-plugin-statusbar”: “^2.4.2”,
“eslint”: “^7.6.0”,
“eslint-plugin-import”: “2.22.1”,
“eslint-plugin-jsdoc”: “30.7.6”,
“eslint-plugin-prefer-arrow”: “1.2.2”,
“jasmine-core”: “~3.8.0”,
“jasmine-spec-reporter”: “~5.0.0”,
“karma”: “~6.3.2”,
“karma-chrome-launcher”: “~3.1.0”,
“karma-coverage”: “~2.0.3”,
“karma-coverage-istanbul-reporter”: “~3.0.2”,
“karma-jasmine”: “~4.0.0”,
“karma-jasmine-html-reporter”: “^1.5.0”,
“protractor”: “~7.0.0”,
“ts-node”: “~8.3.0”,
“typescript”: “~4.4.4”
},
“description”: “An Ionic project”,
“cordova”: {
“plugins”: {
“cordova-plugin-statusbar”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-ionic-webview”: {},
“cordova-plugin-ionic-keyboard”: {}
},
“platforms”: [
“android”
]
}
}

Have you considered using Capacitor?

I Want to be on Cordova… Caoacitor is not an option for now. My environment everything was working fine. After I upgraded to the latest Node / NVM / Ionic/ Codova it stopped working. I have updated the ionic to latest version ionic 6.19 .0. But still not working.