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


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:

info AppiumDoctor Appium Doctor v.1.13.0
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor :heavy_check_mark: The Node.js binary was found at: /home/robinson/.nvm/versions/node/v10.9.0/bin/node
info AppiumDoctor :heavy_check_mark: Node version is 10.9.0
WARN AppiumDoctor :heavy_multiplication_x: ANDROID_HOME is set to ‘/Applications/ADT/sdk’ but this is NOT a valid path!
WARN AppiumDoctor :heavy_multiplication_x: JAVA_HOME is NOT set!
WARN AppiumDoctor :heavy_multiplication_x: adb could NOT be found at ‘/Applications/ADT/sdk/platform-tools/adb’!
WARN AppiumDoctor :heavy_multiplication_x: android could NOT be found at ‘/Applications/ADT/sdk/tools/android’!
WARN AppiumDoctor :heavy_multiplication_x: emulator could NOT be found at ‘/Applications/ADT/sdk/tools/emulator’!
WARN AppiumDoctor :heavy_multiplication_x: Bin directory for $JAVA_HOME is not set
info AppiumDoctor ### Diagnostic for necessary dependencies completed, 6 fixes needed. ###
info AppiumDoctor
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor :heavy_multiplication_x: opencv4nodejs cannot be found.
info AppiumDoctor :heavy_check_mark: ffmpeg is installed at: /usr/bin/ffmpeg. ffmpeg version 4.1.4-1 Copyright © 2000-2019 the FFmpeg developers
WARN AppiumDoctor :heavy_multiplication_x: mjpeg-consumer cannot be found.
WARN AppiumDoctor :heavy_multiplication_x: bundletool.jar cannot be found
info AppiumDoctor ### Diagnostic for optional dependencies completed, 3 fixes possible. ###
info AppiumDoctor
info AppiumDoctor ### Manual Fixes Needed ###
info AppiumDoctor The configuration cannot be automatically fixed, please do the following first:
WARN AppiumDoctor ➜ Manually configure ANDROID_HOME.
WARN AppiumDoctor ➜ Manually configure JAVA_HOME.
WARN AppiumDoctor ➜ Manually install adb and add it to PATH.
WARN AppiumDoctor ➜ Manually install android and add it to PATH.
WARN AppiumDoctor ➜ Manually install emulator and add it to PATH.
WARN AppiumDoctor ➜ Add ‘$JAVA_HOME/bin’ to your PATH environment
info AppiumDoctor
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor ➜ Why opencv4nodejs is needed and how to install it:
WARN AppiumDoctor ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with ‘npm i -g mjpeg-consumer’.
WARN AppiumDoctor ➜ bundletool.jar is used to handle Android App Bundle. Please read to install it
info AppiumDoctor
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!
info AppiumDoctor

You need to set the ANDROID_HOME to the right path of the Android SDK and set the JAVA_HOME environment variable, and then add them to you path.

What shell are you using?

Leaving the solution here, incase anyone faced similar problem in Mac Catalina, when running Appium C# script to initialise Android driver. Tried fixing .bash_profile and .zprofile files as mentioned in many answers, nothing seem to work.

Then, decided to explicitly set ANDROID_HOME and JAVA_HOME environment variables programmatically as follows, before initialising Android driver, it finally worked:

    Environment.SetEnvironmentVariable("ANDROID_HOME", "/Users/{username}/Library/Android/sdk");
    Environment.SetEnvironmentVariable("JAVA_HOME", "/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home");

Hi, Can you help with this

I have given same environment variables in bash profile. But still Appium throws me error as follow:

“An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported”

Please find my bash profile

export ANDROID_HOME=/Users/kalvabalarangasai/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/30.0.2

I solved this problem by starting the appium server click config button & place both android SDK path on ANDOID_HOME & place java installed path at JDK then you are good to go


This was ding ding!!! :bell: