Appium ANDROID_HOME环境变量问题

时间:2018-01-10 16:31:10

标签: appium

新年快乐,如果有人能帮助或解决这个问题,我将非常感激。

我刚刚在MAC OS High Sierra v 10.13.2上设置了appium 1.7.2服务器,通过以下命令运行appium。 appium -a 127.0.0.1 -p 4723 --log-level=debug

以下是我的.bash_profile

n.nadarajah@EGHJ-MACRDV01 ~ $ cat ~/.bash_profile
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
ANDROID_HOME=/Users/n.nadarajah/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
ANDROID_TOOLS=$ANDROID_HOME/tools
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:$JAVA_HOME:$ANDROID_HOME:
$ANDROID_PLATFORM_TOOLS:$ANDROID_TOOLS"
export PATH

回应$ ANDRIOD_HOME env变量

n.nadarajah@EGHJ-MACRDV01 ~ $ echo $ANDROID_HOME
/Users/n.nadarajah/Library/Android/sdk

以下是Appium登录测试执行情况。

n.nadarajah@EGHJ-MACRDV01 ~ $ appium -a 127.0.0.1 -p 4723 --log-l . 
level=debug
info: Welcome to Appium v1.4.16 (REV 
ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"address":"127.0.0.1"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"capabilities":{"alwaysMatch":
{"platformName":"Android"},"firstMatch":
[{}]},"desiredCapabilities":{"deviceName":"Android 
Emulator","app":"/Users/n.nadarajah/sites/Resilient-
QA/EndToEndTesting/apks/app-
debug.apk","platformName":"Android","automationName":"appium",
"appPackage":"com.resilientplc.smartnumbers.debug"}}
info: Client User-Agent string: Python http auth
info: [debug] No appActivity desired capability or server param. 
Parsing from apk.
info: [debug] Using local app from desired caps: 
/Users/n.nadarajah/sites/Resilient-QA/EndToEndTesting
/apks/app-debug.apk
info: [debug] Creating new appium session 
a5cfbee9-bcd6-41af-a90c-0389ab244d2c
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_151
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] executing cmd: which adb
info: [debug] Using adb from /Users/n.nadarajah/
Library/Android/sdk/platform-tools/adb
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.
info: [debug] executing cmd: which 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] 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 ADB.<anonymous> 
(/usr/local/lib/node_modules/appium
/node_modules/appium-adb/lib/adb.js:126:12)
    at ChildProcess.exithandler (child_process.js:279:5)
    at ChildProcess.emit (events.js:159:13)
    at maybeClose (internal/child_process.js:943:16)
    at Socket.stream.socket.on (internal/child_process.js:363:11)
    at Socket.emit (events.js:159:13)
    at Pipe._handle.close [as _onclose] (net.js:568: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 164.317 ms - 344

问题: 1.为什么appium看不到系统环境变量?

我已经尝试过appium服务器版本1.7.2&amp; 1.7.1&amp; 1.6.2&amp; 1.4.16症状相同。 有人可以帮我解决这个问题。

由于 尼鲁

4 个答案:

答案 0 :(得分:1)

在莫哈韦沙漠为我工作。

编辑~/.bash_<profile or rc>后,我使用:

source ~/.bash_<profile or rc>

它不仅加载新变量值,还报告文件中的任何错误。

答案 1 :(得分:0)

我已经深究这个问题, 结果我错过了另一个Android env变量。

在上述情况下,我错过了 ANDROID_BUILD_TOOLS

在撰写本文时,以下是appium所需的Env变量列表。

ANDROID_HOME=/Users/n.nadarajah/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/
Contents/Home/bin
ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
ANDROID_TOOLS=$ANDROID_HOME/tools
ANDROID_BUILD_TOOLS=$ANDROID_HOME/build-tools/27.0.3

将所有上述env变量附加到$ PATH

答案 2 :(得分:0)

这是环境变量的工作清单:

  

导出ANDROID_HOME = / Users / user / Library / Android / sdk

     

导出PATH = $ ANDROID_HOME /:$ PATH
  出口   PATH = $ ANDROID_HOME /平台工具/:$ PATH
  出口   PATH = $ ANDROID_HOME / tools /:$ PATH export PATH = / usr / local / bin /:$ PATH

     

launchctl setenv ANDROID_HOME / Users / user / Library / Android / sdk

适用于highSierra,当然,调整你的路径......

答案 3 :(得分:0)

这里我已经在默认路径中安装了 android studio。

首先设置 Android 主页:创建一个新的系统变量

ANDROID_HOME : C:\Users\<user name>\AppData\Local\Android\Sdk

在路径系统变量中添加以下三个路径

C:\Users\<user name>\AppData\Local\Android\Sdk\platform-tools
C:\Users\<user name>\AppData\Local\Android\Sdk\tools
C:\Users\<user name>\AppData\Local\Android\Sdk\tools\bin