Ionic cordova build android throwing error in Ionic 6 project

I am getting below error when I am trying to run ionic cordova prepare android command on Mac.

ng run app:ionic-cordova-build --platform=android
An unhandled exception occurred: Project target does not exist.
See "/private/tmp/ng-ga2aoC/angular-errors.log" for further details.
[ERROR] An error occurred while running subprocess ng.
        
        ng run app:ionic-cordova-build --platform=android exited with exit code
        127.
        
        Re-running this command with the --verbose flag may provide more
        information.
3 Likes

If you run this command: ng add @ionic/cordova-builders it should add the required builders that are missing from the angular.json file generated by the Ionic CLI.

6 Likes

Thanks a lot for your help in this regard.

You saved my day bro @jwt02180 , Good job, I was frustrated to find a solution for my new app using the latest versions of ionic, Cordova and angular and nothing worked but yours, how did you know that?

A combination of reading the Ionic blog post and package README.

1 Like

Thank you .This is work properly

The Ionic CLI has a new release that fixed this issue, v6.19.0

It helps a lot, but after this, now I’m getting the error:

A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

even with my bundle.gradle being configurated with the version

allprojects {
    apply from: 'repositories.gradle'
    repositories repos

    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="27.0.3" //String
      defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
      defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
     
    }
}

This is unrelated to the original post, so I’d recommend creating your own to get help with the issue you’re having.

1 Like