Problem parsing package and activity from manifest: Error: Could not find aapt. Please set the ANDROID_HOME environment variable

Hi All,

I have done all proper setup to run the mobile automation script from Linux machine(Script is there in linux machine) and running in Windows machine(Target machine).

The node is registered successfully and parameters also passing properly, but while running i am getting below error. please find the below log. Please help me in solving this issue.

#######################################################################################
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
warn: 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 aapt.
info: [debug] executing cmd: where aapt
error: Problem parsing package and activity from manifest: Error: Could not find aapt. Please set the ANDROID_HOME environment variable with the Andro
id SDK root directory path.
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not find aapt. Please set the ANDROID_HOME environment variable with the Android SDK r
oot directory path.
info: [debug] Error: Could not find aapt. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:126:12)
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find aa
pt. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)”,“origValue”:“Could not find aapt. Please set the ANDR
OID_HOME environment variable with the Android SDK root directory path.”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 473.938 ms - 344
#######################################################################################

Have you set the environment variable for the Android SDK ? Something like:

export PATH=$PATH:/Users/<USERNAME>/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/<USERNAME>/Library/Android/sdk/tools
export ANDROID_HOME=/Users/<USERNAME>/Library/Android/sdk/

At least for OSX it would like that, not sure about Windows, maybe that helps:

I set environment variables in windows machine(because my windows machine is the target machine - where i am running my scripts and appium installed). I guess the above environment variable setting is not required in linux machine because i have only the script in linux machine. Please correct me if i am wrong.

Do you start the Appium server manually (on the Windows machine) before starting your test script ? Is it giving you errors as well ?