【问题标题】:Original error: packageAndLaunchActivityFromManifest failed. Original error: Could not find 'aapt' in PATH原始错误:packageAndLaunchActivityFromManifest 失败。原始错误:在 PATH 中找不到“aapt”
【发布时间】:2020-03-29 09:19:40
【问题描述】:

我正在尝试在 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

【问题讨论】:

    标签: android node.js sdk appium


    【解决方案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 的位置发生变化,您就不必更改所有变量。

    【讨论】:

    • /var/root/.bashrc: No such file or directory 否则谢谢,我重用了我的 ANDROID_HOME 目前我正在使用source ~/.bash_profile 运行,我在编辑环境后重新启动了我的计算机。 var.s,问题仍然存在
    猜你喜欢
    • 2018-12-14
    • 2022-10-24
    • 1970-01-01
    • 2019-10-18
    • 1970-01-01
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多