Error: Could not find aapt

Attempting to run Appium from the command line but receiving an error. It appears it id finding my adb device but is not actually launch my app. My Andriod HOME_ENVIROMENT is set up per the Appium documentation and has been working for the GUI. Note my caps are defined in my script and have also been working fine with the GUI. I am using Genymotion for my Emulator.

Log:

harman:~/ $ appium [16:30:04]
info: Welcome to Appium v1.2.3 (REV 90d746b373f55e8653a251d2ce8c62df37941919)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {“desiredCapabilities”:{“platformName”:“Android”,“platformVersion”:“4.3”,“deviceName”:“Android Emulator”,“app”:"/Users/sharman/Desktop/app-debug.apk",“appium-version”:“1.1”,“name”:“Android - basic test”}}
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appium-version, name
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: /Users/sharman/Desktop/app-debug.apk
info: [debug] Creating new appium session b5252f0e-01b0-4828-afef-c48b6b790cfc
info: Starting android appium
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: [debug] Checking whether adb 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 adb.
info: [debug] Using adb from /Users/sharman/Mobiquity/Android/sdk/platform-tools/adb

info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing: “/Users/sharman/Mobiquity/Android/sdk/platform-tools/adb” devices
info: [debug] 1 device(s) connected
info: Found device 192.168.56.101:5555
info: [debug] Setting device id to 192.168.56.101:5555
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing: “/Users/sharman/Mobiquity/Android/sdk/platform-tools/adb” -s 192.168.56.101:5555 wait-for-device
info: [debug] executing: “/Users/sharman/Mobiquity/Android/sdk/platform-tools/adb” -s 192.168.56.101:5555 shell “echo ‘ready’”
info: [debug] Starting logcat capture
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.
error: Problem parsing package and activity from manifest: Error: Could not find aapt. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
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 root directory path.
info: [debug] Error: Could not find aapt. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at null. (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/adb.js:113:12)
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Socket. (child_process.js:966:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find aapt. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)”,“origValue”:“Could not find aapt. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 7102.748 ms - 344

Verify SDK path in the eclipse matches the path variable.

1 Like

Hi Antony_Barnabas,

I am also facing same issue…please help me to resolve.

Also encountering this issue. Has a solution been found for this?

Your bash_profile should look something like this to get it working properly

export ANDROID_HOME=/usr/local/opt/android-sdk
PATH=$PATH:$ANDROID_HOME/build-tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/tools

aapt tool is inside the build-tools folder and thats needed to be downloaded from the sdk manager.

1 Like

If you are running Appium with android sdk tool and getting the error aapt.exe not found … then
please update the capablities of Android Version to the right version

for example: I have connected Android 7.1.1 device to system and executing testing on this device then I need to setup the capablity as
.setCapability(“platformversion”, “7.1.1”);

This error is displayed when different OS version device is defined and different device is connected.

I faced similar problem.

What i missed: build-tools was not set in my (bashrc)
Solution: export PATH=$ANDROID_HOME/build-tools/:$PATH

And thus fixed the problem.