ANDROID_HOME 和 ANDROID_SDK_ROOT 环境变量均未导出 - Windows10

问题描述 投票:0回答:8

我是初学者,正在学习appium工具。

尝试启动 appium 会话并收到错误

An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported

使用窗口 10。

appium
8个回答
22
投票

是的,我也遇到过这个问题。

但是,这些环境变量已经设置正确了。最后,我解决了这个问题——很简单。 在主 UI 中,

Edit Configurations
,设置请求的变量并重新启动。

问题解决了。


1
投票

我也有同样的问题。所有环境变量都已设置正确。我发现根本原因是当我强制退出 Appium Desktop 应用程序时,在主机 0.0.0.0 的端口 4723 上运行的未完成的进程。一旦我杀死了在这个地址运行的进程,我就不再看到问题了

杀死正在使用的地址的链接:Appium问题。如果出现“listen eaddrinuse:地址已在使用中”,如何阻止它?怎么还不停?


1
投票

如果您刚刚使用

ANDROID_HOME
更新了 rc 文件,请务必在新窗口中重新启动
cli appium server
。之前启动的 appium 服务器会一直抱怨。


0
投票

我也遇到过这个问题。我注意到大多数时候你实际上是在设置 ANDROID_HOME 但你在值中缺少拼写。检查并确保您复制路径而不是键入路径,因为当您键入路径时,您可能会拼错 android 拼写。因此,将 Android 安装路径复制到系统变量的名称/值对中。


0
投票

我在 Mac 中也面临同样的问题。 我正在尝试以编程方式启动 Appium,这是通过 AppiumDriverLocalService 成功的。

Appium启动并加载所有功能后,当我尝试设置驱动程序(AppriumDriver)时,它会给出错误“org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。请检查服务器日志以获取更多详细信息。原始错误:处理命令时发生未知服务器端错误。原始错误:既没有导出 ANDROID_HOME 也没有导出 ANDROID_SDK_ROOT 环境变量。请阅读 https://developer.android.com/studio/command-线/变量了解更多详细信息”


0
投票

问题:

An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported

如果您在终端上输入

appium-doctor
将在路径 ANDROID_HOME -> X 上出现错误,而不是像这样检查:

info AppiumDoctor Appium Doctor v.1.16.0
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor  ✔ The Node.js binary was found at: /Users/wiwa/.nvm/versions/node/v16.17.0/bin/node
info AppiumDoctor  ✔ Node version is 16.17.0
info AppiumDoctor  ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ DevToolsSecurity is enabled.
info AppiumDoctor  ✔ The Authorization DB is set up properly.
info AppiumDoctor  ✔ Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.38.0
info AppiumDoctor  ✔ HOME is set to: /Users/wiwa
info AppiumDoctor  ✖ ANDROID_HOME is set to: /Users/wiwa/Library/Android/sdk
info AppiumDoctor  ✔ JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
info AppiumDoctor    Checking adb, android, emulator
info AppiumDoctor      'adb' is in /Users/wiwa/Library/Android/sdk/platform-tools/adb
info AppiumDoctor      'android' is in /Users/wiwa/Library/Android/sdk/tools/android
info AppiumDoctor      'emulator' is in /Users/wiwa/Library/Android/sdk/emulator/emulator
info AppiumDoctor  ✔ adb, android, emulator exist: /Users/wiwa/Library/Android/sdk
info AppiumDoctor  ✔ 'bin' subfolder exists under '/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home'
info AppiumDoctor ### Diagnostic for necessary dependencies completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor  ✖ opencv4nodejs cannot be found.
info AppiumDoctor  ✔ ffmpeg is installed at: /usr/local/bin/ffmpeg. ffmpeg version 5.1 Copyright (c) 2000-2022 the FFmpeg developers
WARN AppiumDoctor  ✖ mjpeg-consumer cannot be found.
WARN AppiumDoctor  ✖ set-simulator-location is not installed
WARN AppiumDoctor  ✖ idb and idb_companion are not installed
WARN AppiumDoctor  ✖ applesimutils cannot be found
info AppiumDoctor  ✔ ios-deploy is installed at: /Users/wiwa/.nvm/versions/node/v16.17.0/bin/ios-deploy. Installed version is: 1.11.4
WARN AppiumDoctor  ✖ bundletool.jar cannot be found
WARN AppiumDoctor  ✖ gst-launch-1.0 and/or gst-inspect-1.0 cannot be found
info AppiumDoctor ### Diagnostic for optional dependencies completed, 7 fixes possible. ###
info AppiumDoctor
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor  ➜ Why opencv4nodejs is needed and how to install it: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/image-comparison.md
WARN AppiumDoctor  ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'.
WARN AppiumDoctor  ➜ set-simulator-location is needed to set location for Simulator. Please read https://github.com/lyft/set-simulator-location to install it
WARN AppiumDoctor  ➜ Why idb is needed and how to install it: https://github.com/appium/appium-idb
WARN AppiumDoctor  ➜ Why applesimutils is needed and how to install it: http://appium.io/docs/en/drivers/ios-xcuitest/
WARN AppiumDoctor  ➜ bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it
WARN AppiumDoctor  ➜ gst-launch-1.0 and gst-inspect-1.0 are used to stream the screen of the device under test. Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details
info AppiumDoctor
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!
info AppiumDoctor

如果您使用 mac 或 linux 使用 .bashrc 或 .zshrc 只需输入以下解决方案:

source ~/.bashrc

source ~/.zshrc

并再次检查使用

appium-doctor
如果已经检查 ANDROID_HOME 它已经解决而没有错误:)


0
投票

@dhan bycode 我已经尝试过 appium-doctor & source ~/.zshrc 这些命令都不适合我。


-1
投票

如果您安装了 android studio,则缺少环境变量。只需在环境变量中设置路径即可。

这是一个链接,请点击以下链接: http://www.automationtestinghub.com/setup-android-environment-variables/

© www.soinside.com 2019 - 2024. All rights reserved.