Peter Toth
Peter Toth

Reputation: 770

Original error: packageAndLaunchActivityFromManifest failed. Original error: Could not find 'aapt' in PATH

I'm trying to set up an android automated test with appium on mac.

I have already set android home in my bash_profile:

export ANDROID_HOME=/Users/peter.szabototh/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
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/29.0.2/
export PATH=${PATH}:${JAVA_HOME}

In my sdk/build-tools folder, which I have added to the enviremental variables, I have aapt and aapt2 as well. However, I get this error message:

An unknown server-side error occurred while processing the command. Original error: packageAndLaunchActivityFromManifest failed. Original error: Could not find 'aapt' in PATH. Please set the ANDROID_HOME or ANDROID_SDK_ROOT environment variables to the correct Android SDK root directory path.

An interesting thing is that I can build my android apk with no problems, which use the same enviremental variables.

I am running appium with sudo and from my bash_profile.

Here is my full log:

15:11:34] I/update - chromedriver: file exists /Users/peter.szabototh/Documents/ionic/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.zip
[15:11:34] I/update - chromedriver: unzipping chromedriver_78.0.3904.105.zip
[15:11:35] I/update - chromedriver: setting permissions to 0755 for /Users/peter.szabototh/Documents/ionic/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105
[15:11:35] I/update - chromedriver: chromedriver_78.0.3904.105 up to date
Test is running with ID: 812527706099
[15:11:35] I/launcher - Running 1 instances of WebDriver
[15:11:35] I/hosted - Using the selenium server at http://localhost:4723/wd/hub
[15:11:35] E/launcher - An unknown server-side error occurred while processing the command. Original error: packageAndLaunchActivityFromManifest failed. Original error: Could not find 'aapt' in PATH. Please set the ANDROID_HOME or ANDROID_SDK_ROOT environment variables to the corect Android SDK root directory path.
[15:11:35] E/launcher - WebDriverError: An unknown server-side error occurred while processing the command. Original error: packageAndLaunchActivityFromManifest failed. Original error: Could not find 'aapt' in PATH. Please set the ANDROID_HOME or ANDROID_SDK_ROOT environment variables to the corect Android SDK root directory path.
    at Object.checkLegacyResponse (/Users/peter.szabototh/Documents/ionic/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/Users/peter.szabototh/Documents/ionic/node_modules/selenium-webdriver/lib/http.js:509:13)
    at /Users/peter.szabototh/Documents/ionic/node_modules/selenium-webdriver/lib/http.js:441:30
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.createSession()
    at Function.createSession (/Users/peter.szabototh/Documents/ionic/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at createDriver (/Users/peter.szabototh/Documents/ionic/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/Users/peter.szabototh/Documents/ionic/node_modules/selenium-webdriver/index.js:635:14)
    at Hosted.getNewDriver (/Users/peter.szabototh/Documents/ionic/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
    at Runner.createBrowser (/Users/peter.szabototh/Documents/ionic/node_modules/protractor/built/runner.js:195:43)
    at /Users/peter.szabototh/Documents/ionic/node_modules/protractor/built/runner.js:339:29
    at _fulfilled (/Users/peter.szabototh/Documents/ionic/node_modules/protractor/node_modules/q/q.js:834:54)
    at /Users/peter.szabototh/Documents/ionic/node_modules/protractor/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/peter.szabototh/Documents/ionic/node_modules/protractor/node_modules/q/q.js:796:13)
    at /Users/peter.szabototh/Documents/ionic/node_modules/protractor/node_modules/q/q.js:556:49
[15:11:35] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! talentuno-ionic-mobile-app@ e2e: `node ./node_modules/@angular/cli/bin/ng e2e`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the talentuno-ionic-mobile-app@ e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2019-12-04T14_11_35_949Z-debug.log
make: *** [test] Error 1

Upvotes: 0

Views: 236

Answers (1)

Parth Pitroda
Parth Pitroda

Reputation: 997

First make sure that you've got the SDK installed correctly and that your path in ANDROID_HOME points to the folder containing the /bin folder.

Then try running:

source ~/.bashrc

or log-in and log-out to apply the new changes in the bash file.

You could also reuse your ANDROID_HOME variable:

export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools

This way you don't have to change all the variables if the location of the SDK changes.

Upvotes: 1

Related Questions