SDK error when building android application below api level 24

I built a simple application for testing. When I build for android sdk versions equal to or greater than 24 it recognizes the SDK and does the correct procedure, but if you try to build other versions like 22 and 23 (Android 5.1 and 6.0) an error appears and the procedure is not completed . If it is SDK 23 the situation is even worse as it cannot even add the Android platform to the ionic project, unlike API level 23, which in turn adds the platform but cannot build it.

What I’ve tried: I added the sdk and gradle path as a system variable by the windows manager, I changed the SDK versions for testing several times, concluding that the SDK only doesn’t work when less than 24, I updated the gradle and I’ve already added the commands:

set ANDROID_HOME=C:\Users\Herick Pereira\AppData\Local\Android\sdk
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

My error:

Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.

Used configuration:


   Ionic CLI                     : 6.12.3 (C:\Users\Herick 
   Ionic Framework               : @ionic/angular 5.5.2
   @angular-devkit/build-angular : 0.1000.8
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3


   Cordova CLI       : 10.0.0
   Cordova Platforms : android 7.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 4 other plugins)


   cordova-res : not installed
   native-run  : 1.3.0


   NodeJS : v14.15.4 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.10
   OS     : Windows 10