求教appum的错误解决办法

运行代码
from appium import webdriver
desired_caps={}
desired_caps[‘platformName’]=‘Android’
desired_caps[‘platformVersion’]=‘6.0’
desired_caps[‘deviceName’]=‘emulator-5554’

desired_caps[‘appPackage’]=‘com.android.settings’
desired_caps[‘appActivity’]=‘com.android.settings.Settings’

driver=webdriver.Remote(‘http://localhost:4723/wd/hub’,desired_caps)
print(“启动【设置】应用”)
driver.quit()

报错信息
E selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error getting device platform version. Original error: Error executing adbExec. Original error: ‘Command ‘D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s URU0218A25003520 shell getprop ro.build.version.release’ exited with code 1’; Stderr: ‘error: device unauthorized.
E This adb server’s $ADB_VENDOR_KEYS is not set
E Try ‘adb kill-server’ if that seems wrong.
E Otherwise check for a confirmation dialog on your device.’; Code: ‘1’

报错信息写的很清楚了,因为你的手机未被授权处于:unauthorized 状态,所以导致了报错,
且下面报错信息中给到了解决方法。

ro.build.version.release’ exited with code 1’; Stderr: ‘error: device unauthorized.
E This adb server’s $ADB_VENDOR_KEYS is not set
E Try ‘adb kill-server’ if that seems wrong.
E Otherwise check for a confirmation dialog on your device.’; Code: ‘1’

具体操作:
1)adb kill-server
2)adb start-server
3)adb devices(查看是不是处于devices状态)

image
如果上述方法还不行的话,重新插拔数据线后,看下手机是否有提示:“是否信任电脑”,有的话点击确定,问题解决。如果没弹的话检查下开发者模式中的配置情况再进行以上操作。

好的,谢谢了