原始错误:packageAndLaunchActivityFromManifest失败。原始错误:在PATH

时间:2019-12-04 14:26:17

标签: android node.js sdk appium

我正在尝试在Mac上使用appium设置android自动化测试。

我已经在我的bash_profile中设置了android home:

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}

在我已添加到环境变量的sdk/build-tools文件夹中,我也有aaptaapt2。但是,我收到此错误消息:

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.

有趣的是,我可以毫无问题地构建我的android apk,它使用相同的环境变量。

我正在通过sudo和bash_profile运行appium。

这是我的完整日志:

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

1 个答案:

答案 0 :(得分:1)

首先,请确保您已正确安装SDK,并且ANDROID_HOME中的路径指向包含/ bin文件夹的文件夹。

然后尝试运行:

source ~/.bashrc

或登录和注销以在bash文件中应用新更改。

您还可以重复使用ANDROID_HOME变量:

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

这样,如果SDK的位置发生变化,则不必更改所有变量。