A problem occurred evaluating project ':app'. > Unable to determine Android SDK directory

l have android project using ionic and cordova . When I run ionic cordova build android --release command in root of ionic project, I am getting “BUILD SUCCESSFUL”

app-release-unsigned.apk

But when i want to release bundle app from platforms/android root .i will have following error :

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
config.xml
../config.xml
../../config.xml
../../../config.xml
preference = 10
name = ScrollEnabled
name = android-minSdkVersion
name = BackupWebStorage
name = SplashMaintainAspectRatio
name = AutoHideSplashScreen
name = SplashScreenDelay
name = SplashShowOnlyFirstTime
name = SplashScreen
name = GOOGLE_MAPS_ANDROID_API_KEY
name = GOOGLE_MAPS_IOS_API_KEY
---->PLAY_SERVICES_VERSION = 16.0.0
---->ANDROID_SUPPORT_V4_VERSION = 27.1.1
An exception occurred while trying to find the Android build tools.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/user name /bgw/platforms/android/CordovaLib/cordova.gradle' line: 112

* What went wrong:
A problem occurred evaluating project ':app'.
> Unable to determine Android SDK directory.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

ionic info :

Ionic:

   Ionic CLI                     : 6.11.11 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.13
   @angular-devkit/build-angular : 0.13.10
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.10
   @ionic/angular-toolkit        : 1.4.1

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : 5.0.4, android 9.0.0, browser
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 11 other plugins)

Utility:

   cordova-res                          : 0.15.1
   native-run (update available: 1.2.1) : 1.0.0

System:

   Android SDK Tools : 26.1.1 (/Users/user name/Library/Android/sdk)
   NodeJS            : v12.18.3 (/usr/local/bin/node)
   npm               : 6.14.8
   OS                : macOS Catalina
   Xcode             : Xcode 11.6 Build version 11E708

cordova requirements android :

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-30,android-29,android-28,android-27,android-26
Gradle: installed /Volumes/secdisk/gradle-6.5.1/bin/gradle

.bash_profile:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_251`
export PATH=$JAVA_HOME/bin:$PATH
export GRADLE_HOME=/Volumes/secdisk/gradle-6.5.1/bin

export ANDROID_HOME=/Users/user name /Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/platforms
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/./gradlew
export PATH=$PATH:$ANDROID_HOME/build-tools

export PATH=$PATH:$GRADLE_HOME

Any idea please ?

My bash file is simply this

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_SDK_ROOT=/home/user/Android/Sdk
export PATH=${PATH}:$ANDROID_SDK_ROOT/tools
export PATH=${PATH}:$ANDROID_SDK_ROOT/platform-tools

export GRADLE_HOME=/opt/gradle/gradle-6.6.1
export PATH=${GRADLE_HOME}/bin:${PATH}

You must have an android image in this folder…

Please how did you resolve this? Getting exactly the same output.