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

Francis · 2019年12月11日 · 最后由 Francis 回复于 2019年12月21日 · 2503 次阅读

问题描述:

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 报错日志:

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 版本及环境

Android SDK 版本

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

共收到 8 条回复 时间 点赞

有没有遇到过的同学啊?

apk 有问题吧,清除缓存试试

cmlanche 回复

试过,没有用。。

wtnhz 回复

好的 我按照问题单试试看。

Francis 回复

同学你的问题解决了吗,我今天也遇到同样的问题,我重新下载了 appium-uiautomator2-server-debug-androidTest,但是每次发现运行后大小都变成 0 了

这个问题我已经解决了,java 的 jdk 版本太高,降低版本到 1.8 就可以了,弄了 2 天的时间,最后是因为版本的问题

imax_test 回复

是的,我也是版本问题,我是把 SDK 的 build-tools 版本从 29 降到了 28.0.3,就好了。所以最好不要用最新的,用稳定的版本。

Francis 关闭了讨论 12月21日 01:26
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册