Throwing error ANDROID_HOME is not set in a valid path


I am setting up appium for executing tests on Android devices on a mac machine. I am also using serenity for reporting. When I start running the test I am getting the following error

Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: packageAndLaunchActivityFromManifest failed. Original error: Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path. (WARNING: The server did not provide any stacktrace information)

I tried printing the ANDROID_HOME variable from intellij and it is reflecting correctly. Please help