Throwing error ANDROID_HOME is not set


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

Hi @PoornimaSuraj,
Trye this:

  1. Open the terminal and type :

export ANDROID_HOME=/Applications/ADT/sdk

  1. Add this to the PATH environment variable


  1. After this, verify the settings by running:


Hope this works

1 Like

Hey @PoornimaSuraj

It will work Whatever @sachin925 says .If you still face the issue copy below thing in bash_profile

1.Open The Terminal
2.Type below command
nano ~/.bash_profile

then one window will open add the path as per ur system directory

export ANDROID_HOME=/Users/xxx/Library/Android/sdk
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platforms-tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/27.0.1
export PATH=${PATH}:${JAVA_HOME}

Once copied save the file by pressing command+x .

Hope this will resolve issue permanently


Thank you, @sachin925 @Rajesh_RK … its working now. I had set the value in bash_profile, but the values did not get reflected. A couple of restarts later, problem got fixed :slight_smile:

@PoornimaSuraj : Good to know…

@Rajesh_RK @sachin925 can you please help me, I have the same problem on windows 10

@Reem_Nasser : In windows 10 u have to set the environment variables of ANDROID_HOME and JAVA_HOME…

In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.

I have the same errors although I follow the steps.

Can anyone please give me an instructions to fix?

Hello @Pac_Chan , from your logs, it can correctly get the path you have set in your bash_profile, but it says it is not a valid path. Are you able to navigate to the location /Users/Pac/Library/Android/sdk from terminal?

I have the same issue! I set variables in mi ~/.bash_profile but nothing. I have Mojave as OS.
Please help

Hi ,

I am getting the same error even after setting everything, Please can you check once ?

Here is my nano ~/.profile

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

export ANDROID_HOME=/Users/krishnakiran/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/build-tools/29.0.0:$PATH

launchctl setenv ANDROID_HOME /Users/krishnakiran/Library/Android/sdk

Heres the which appt on terminal


Here’s the error message when i run on eclipse

e[35m[Appium]e[39m Welcome to Appium v1.13.0
e[35m[Appium]e[39m Non-default server args:
e[35m[Appium]e[39m address:
e[35m[Appium]e[39m fullReset: true
e[35m[Appium]e[39m Deprecated server args:
e[35m[Appium]e[39m e[31m–full-resete[39m => --default-capabilities ‘{“fullReset”:true}’
e[35m[Appium]e[39m Default capabilities, which will be added to each request unless overridden by desired capabilities:
e[35m[Appium]e[39m fullReset: true
e[35m[Appium]e[39m Appium REST http interface listener started on
Appium server started.
08 Jul 2019 11:05:07 INFO logger - Appium server started successfully
08 Jul 2019 11:05:07 INFO logger - --------------------------------------
e[35m[HTTP]e[39m e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m
e[35m[HTTP]e[39m e[90m{“desiredCapabilities”:{“app”:"/Users/krishnakiran/Desktop/MobileAutomationFramework-master/app-poquat-release.apk",“appPackage”:“”,“noReset”:false,“automationName”:“UiAutomator2”,“platformName”:“Android”,“deviceName”:“Android Device”},“capabilities”:{“alwaysMatch”:{“appium:app”:"/Users/krishnakiran/Desktop/MobileAutomationFramework-master/app-poquat-release.apk",“appium:appPackage”:“”,“appium:automationName”:“UiAutomator2”,“appium:deviceName”:“Android Device”,“appium:noReset”:false,“platformName”:“android”},“firstMatch”:[{}]}}e[39m
[debug] e[35m[W3C]e[39m Calling AppiumDriver.createSession() with args: [{“app”:"/Users/krishnakiran/Desktop/MobileAutomationFramework-master/app-poquat-release.apk",“appPackage”:“”,“noReset”:false,“automationName”:“UiAutomator2”,“platformName”:“Android”,“deviceName”:“Android Device”},null,{“alwaysMatch”:{“appium:app”:"/Users/krishnakiran/Desktop/MobileAutomationFramework-master/app-poquat-release.apk",“appium:appPackage”:“”,“appium:automationName”:“UiAutomator2”,“appium:deviceName”:“Android Device”,“appium:noReset”:false,“platformName”:“android”},“firstMatch”:[{}]}]
[debug] e[35m[BaseDriver]e[39m Event ‘newSessionRequested’ logged at 1562580308565 (11:05:08 GMT+0100 (British Summer Time))
e[35m[BaseDriver]e[39m The capabilities [“fullReset”] are not standard capabilities and should have an extension prefix
e[35m[Appium]e[39m Appium v1.13.0 creating new AndroidUiautomator2Driver (v1.33.1) session
e[35m[Appium]e[39m Capabilities:
e[35m[Appium]e[39m platformName: android
e[35m[Appium]e[39m app: /Users/krishnakiran/Desktop/MobileAutomationFramework-master/app-poquat-release.apk
e[35m[Appium]e[39m appPackage:
e[35m[Appium]e[39m automationName: UiAutomator2
e[35m[Appium]e[39m deviceName: Android Device
e[35m[Appium]e[39m noReset: false
e[35m[Appium]e[39m fullReset: true
[debug] e[35m[BaseDriver]e[39m W3C capabilities {“alwaysMatch”:{“platformNa… and MJSONWP desired capabilities {“fullReset”:true,“app”:”/U… were provided
[debug] e[35m[BaseDriver]e[39m Creating session with W3C capabilities: {“alwaysMatch”:{"platformNa…
e[35m[BaseDriver]e[39m Session created with session id: 68900c24-5369-48a9-b686-42f36f6e2e70
e[35m[BaseDriver]e[39m Using local app ‘/Users/krishnakiran/Desktop/MobileAutomationFramework-master/app-poquat-release.apk’
[debug] e[35m[UiAutomator2]e[39m Checking whether app is actually present
e[35m[ADB]e[39m The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
[debug] e[35m[UiAutomator2]e[39m Deleting UiAutomator2 session
[debug] e[35m[BaseDriver]e[39m Event ‘newSessionStarted’ logged at 1562580308745 (11:05:08 GMT+0100 (British Summer Time))
[debug] e[35m[W3C]e[39m Encountered internal error running command: Error: Could not find ‘adb’ in PATH. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
[debug] e[35m[W3C]e[39m at ADB. (/Applications/
[debug] e[35m[W3C]e[39m at Generator.throw ()
[debug] e[35m[W3C]e[39m at asyncGeneratorStep (/Applications/
[debug] e[35m[W3C]e[39m at _throw (/Applications/
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session e[39me[31m500e[39m e[90m274 ms - 803e[39m
e[35m[HTTP]e[39m e[90me[39m
It is impossible to create a new session because ‘createSession’ which takes HttpClient, InputStream and long was not found or it is not accessible
Build info: version: ‘3.12.0’, revision: ‘7c6e0b3’, time: ‘2018-05-08T14:04:26.12Z’
System info: host: ‘POQ0026.local’, ip: ‘fe80:0:0:0:10de:7d73:bad7:e4fe%en0’, ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.14.4’, java.version: ‘1.8.0_201’
Driver info: driver.version: AndroidDriver

Hello @Krishna_Kiran_K , have you set the android_home in eclipse run configuration?

Hey @PoornimaSuraj , Yes I did and it did work after that . But is there no way to set this in the code itself rather than setting it up on the Run Config in eclipse ?

Great to know that it worked. Unfortunately, I am not a frequent eclipse user and not sure why the environment variables are not being picked up. Probably a question for the eclipse team? :slight_smile: