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

2019-12-11 20:58:17 +08:00
 Ctry

问题描述:

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 没找到答案。哪位同学遇到过相同相似的问题的,能否指导一下,万分感谢!!

3647 次点击
所在节点    Python
1 条回复
Ctry
2019-12-11 21:15:07 +08:00
有没有大佬知道啊?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/628139

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX