ionic-framework: bug: Building Ionic cordova android returns ERROR "An unhandled exception occurred: Project target does not exist."
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
Current Behavior
Ionic cordova build android is not working and returning the below error:

Expected Behavior
Ionic Cordova should build the project for android normally.
Steps to Reproduce
$ ionic start --cordova
Pick a framework!
Please select the JavaScript framework to use for your new app. To bypass this prompt next time, supply a value for the
--type option.
? Framework: Angular
Every great app needs a name!
Please enter the full name of your app. You can change this at any time. To bypass this prompt next time, supply name,
the first argument to ionic start.
? Project name: temp-ionic6
Let's pick the perfect starter template!
Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your app. To bypass this
prompt next time, supply template, the second argument to ionic start.
? Starter template: sidemenu
ā Preparing directory .\temp-ionic6 in 2.06ms
ā Downloading and extracting sidemenu starter in 474.11ms
....
....
....
....
Your Ionic app is ready! Follow these next steps:
- Go to your new project: cd .\temp-ionic6
- Run ionic serve within the app directory to see your app in the browser
- Run ionic cordova platform add to add a native iOS or Android project using Cordova
- Generate your app icon and splash screens using cordova-res
- Explore the Ionic docs for components, tutorials, and more: https://ion.link/docs
- Building an enterprise app? Ionic has Enterprise Support and Features: https://ion.link/enterprise-edition
$ ionic cordova platform add android
ā Creating .\www directory for you in 3.60ms
> cordova.cmd platform add android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-android@^10.1.1
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: io.ionic.starter
Name: temp-ionic6
Activity: MainActivity
Android target: android-30
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@10.1.1
....
....
....
[cordova-res] Generated 18 resources for android
[cordova-res] Wrote to config.xml
$ionic cordova build android
> ng.cmd run app:ionic-cordova-build --platform=android
An unhandled exception occurred: Project target does not exist.
See "C:\Users\MOALAS~1\AppData\Local\Temp\ng-DDj9ln\angular-errors.log" for further details.
[ERROR] An error occurred while running subprocess ng.
Code Reproduction URL
https://github.com/MoAsmar/temp-ionic6
Ionic Info
Ionic:
Ionic CLI : 6.18.2 (C:\Users\moalasmar\AppData\Roaming\npm\node_modules\@ionic\cli)
Ionic Framework : @ionic/angular 6.0.11
@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 : 1.5.0
System:
Android SDK Tools : 26.1.1 (C:\Users\moalasmar\AppData\Local\Android\Sdk)
NodeJS : v16.14.0 (C:\Program Files\nodejs\node.exe)
npm : 8.5.4
OS : Windows 10
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (3 by maintainers)
For me it got resolved only by just running
ng add @ionic/cordova-builders. No need to change theionic.config.json. Iām using ionic/cli@5.4.16 and cordova 10. Thanks for the help everyone.Ionic CLI v6.19.0 has been released with this fix:
installing latest ionic/cli v6.19.0 fixes the issue. I started a fresh new app with
ionic start my-app tabs --type angular --cordovaand cordova build successful. thank you for your quick reply.There is also a new testing version of the CLI if you would like to give this change a try:
Hey there,
This is due to users needing to add the new
@ionic/cordova-builderspackage if they are updating to@ionic/angular-toolkit@6. This is noted in the breaking changes log: https://github.com/ionic-team/angular-toolkit/releases/tag/%40ionic%2Fangular-toolkit%406.0.0 Developers upgrading their apps should take note of any changes in these logs when updating across major versions of this package.For new applications, developers can run
ng add @ionic/cordova-buildersas noted to resolve the issue. However, I agree that this should be done automatically when creating an app via the CLI. We have a new addition to the Ionic CLI coming soon that will automatically runng add @ionic/cordova-builders. I am going to flag this PR with the team so we can increase its priority.I am going to close this as this is not a bug in Ionic Framework, but you can track progress on this new CLI feature here: https://github.com/ionic-team/ionic-cli/pull/4823. Thanks!