V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Ctry
V2EX  ›  Python

新手搭建 Python +Appium 环境时遇到的无法打开 appium-uiautomator2-server-debug-androidTest.apk 的问题,求大佬指教!

  •  1
     
  •   Ctry · 2019-12-11 20:58:17 +08:00 · 3685 次点击
    这是一个创建于 1808 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题描述:

    Appium 环境已经搭建成功后,连接 Android 真机,写了一个打开手机 Settings 这个应用的 python 脚本。然后运行报错,无法打开 Settings 应用。脚本内容如下:

    from appium import webdriver
    
    
    desired_caps = {}
    desired_caps['automationName'] = 'UiAutomator2'
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '6.0'
    desired_caps['deviceName'] = 'HUAWEI MT7-CL00'
    desired_caps['udid'] = 'G2W0214922003906'
    
    desired_caps['appPackage'] = 'com.android.settings'
    desired_caps['appActivity'] = '.HWSettings'
    
    browser = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    

    报错信息如下:

    Appium 报错日志: https://imgur.com/2TqURdI.jpg

    Python 脚本报错日志:

    Traceback (most recent call last):
      File "E:/Study/appauto.py", line 14, in <module>
        browser = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
      File "D:\Python\lib\site-packages\appium\webdriver\webdriver.py", line 144, in __init__
        proxy
      File "D:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
        self.start_session(capabilities, browser_profile)
      File "D:\Python\lib\site-packages\appium\webdriver\webdriver.py", line 219, in start_session
        response = self.execute(RemoteCommand.NEW_SESSION, parameters)
      File "D:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
        self.error_handler.check_response(response)
      File "D:\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
        raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: zipAlignApk failed. Original error: Command ''D:\\Android SDK Tools\\build-tools\\29.0.2\\zipalign.exe' -f 4 C:\\Users\\Cww03\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-debug-androidTest.apk C:\\Users\\Cww03\\AppData\\Local\\Temp\\20191111-4600-jdyhkf.bntmh\\appium.tmp' exited with code 1. Stdout: ''; Stderr: 'Unable to open 'C:\Users\Cww03\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' as zip archive
    '
    

    环境配置:

    Appium 版本及环境 https://imgur.com/wdzzNi7.jpg

    Android SDK 版本 https://imgur.com/0KqrAqG.jpg

    各位大佬们,Google 没找到答案。哪位同学遇到过相同相似的问题的,能否指导一下,万分感谢!!

    1 条回复    2019-12-11 21:15:07 +08:00
    Ctry
        1
    Ctry  
    OP
       2019-12-11 21:15:07 +08:00
    有没有大佬知道啊?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1240 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 18:03 · PVG 02:03 · LAX 10:03 · JFK 13:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.