【问题标题】:Appium ANDROID_HOME env variable issuesAppium ANDROID_HOME 环境变量问题
【发布时间】:2018-01-10 16:31:09
【问题描述】:

祝大家新年快乐,如果有人可以帮助或阐明这个问题,我将不胜感激。

我刚刚在 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 环境变量

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 server 版本 1.7.2 & 1.7.1 & 1.6.2 & 1.4.16,症状是一样的。 有人可以帮我解决这个问题。

谢谢 尼罗

【问题讨论】:

    标签: appium


    【解决方案1】:

    我已经深入了解了这个问题, 原来我错过了另一个 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
    

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

    【讨论】:

      【解决方案2】:

      在莫哈韦为我工作。

      编辑后~/.bash_&lt;profile or rc&gt;我用:

      source ~/.bash_<profile or rc>
      

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

      【讨论】:

        【解决方案3】:

        这里是环境变量的工作列表:

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

        导出 PATH=$ANDROID_HOME/:$PATH
        出口 PATH=$ANDROID_HOME/platform-tools/:$PATH
        出口 PATH=$ANDROID_HOME/tools/:$PATH export PATH=/usr/local/bin/:$PATH

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

        在 highSierra 上工作,当然,调整你的路径...

        【讨论】:

        • 嗨,@Kovacic 试图将您的代码放在 MacOs High Sierra 10.13.4 版本中它不起作用并说“找不到 Android SDK。确保它已安装。如果它不在默认位置,设置 ANDROID_HOME 环境变量”。但它在 MacOS High Sierra 10.13.3 版本的设备上工作。我在哪里做错了。
        • 确保这是您的路径“/Users/XXXXXXX/Library/Android/sdk”,或在控制台输入“which android”,然后将 /android 替换为“/sdk”,您应该没事
        • 运行“which android” o/p:- is /Users//Library/Android/sdk/tools//android 时获取此输出我如何编辑输出路径。跨度>
        • 嗨,@Kovacic 已经改变了你所说的,但没有运气。有没有版本缺陷。
        【解决方案4】:

        这里我已经在默认路径下安装了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
        

        【讨论】:

          猜你喜欢
          • 2016-07-11
          • 2019-07-25
          • 2020-07-04
          • 2018-08-08
          • 2013-10-02
          • 1970-01-01
          • 2015-04-02
          • 2015-11-23
          相关资源
          最近更新 更多