Ionic Cordova compileSdkVersion is not specified error

In my ionic 6 cordova app, if I use cordova-adroid@11.0 I am getting the below error for gradle build:

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

Ionic Info

Ionic:

   Ionic CLI                     : 6.20.1 (C:\Users\CGauns\AppData\Roaming\nvm\v16.17.1\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.2.3
   @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 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 24 other plugins)

Utility:

   cordova-res : 0.15.4
   native-run  : 1.7.1

System:

   Android SDK Tools : 26.1.1 (D:\Android\sdk)
   NodeJS            : v16.17.1 (C:\Program Files\nodejs\node.exe)
   npm               : 8.15.0
   OS                : Windows 10

Gradle
7.5.1

Java
17.0.3

You need to add the compilesdkVersion value in that file.

@Hills90210 is it over here?

Do you have <preference name="android-targetSdkVersion" value="30" /> specified in the config.xml?

yes. Have set it to 31

This may point you in the right direction: cordova-android-11 build error · Issue #1482 · apache/cordova-android · GitHub.

In short: check your plugins. you have one that needs to be updated.

You can run npm outdate and it will show which packages need updates.

have you resolve it please? where should i add compilesdkVersion value in build.gradle?