Ionic 6 + Cordova: compileSdkVersion is not specified

I’m doing an app using ionic 6 with cordova instead of capacitor. I put this line in my config.xml file

<preference name="android-targetSdkVersion" value="29" />

and this in my file build.gradle

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

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

but when I run ionic cordova build android I still get this error:

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

and it makes not be able to generate the apk of the app

I’m using ubuntu, my gradle version is the last release 7.4.2 and my ionic version is 6.19.0

Someone already got this error before? The ionic serve command work like a charm.

Thanks!

3 Likes