question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Building Ionic cordova android returns ERROR "An unhandled exception occurred: Project target does not exist."

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

Ionic cordova build android is not working and returning the below error:

image

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
raghav14commented, Mar 16, 2022

For me it got resolved only by just running ng add @ionic/cordova-builders. No need to change the ionic.config.json. I’m using ionic/cli@5.4.16 and cordova 10. Thanks for the help everyone.

2reactions
liamdebeasicommented, Mar 15, 2022

Ionic CLI v6.19.0 has been released with this fix:

npm install -g @ionic/cli@latest
Read more comments on GitHub >

github_iconTop Results From Across the Web

An unhandled exception occurred: Project target does not exist
The problem is caused by required builders that are missing from the angular.json file. To install those builders, run:
Read more >
Ionic cordova build android throwing error in Ionic 6 project
I am getting below error when I am trying to run ionic cordova prepare ... An unhandled exception occurred: Project target does not...
Read more >
Building Ionic v6 cordova android angular13 app returns ...
Coding example for the question Building Ionic v6 cordova android angular13 app returns ERROR "An unhandled exception occurred: Project target does not exist....
Read more >
cordova-plugin-firebasex - npm
This plugin is designed to work with Cordova therefore relies on Cordova features such as hook scripts, plugin variables and project structure ...
Read more >
unknown argument: platform [ERROR] an error occurred while ...
I am developing an ionic application. At first my angular cli version is 9.0. When i run the command line"ionic cordova build android",it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found