我最近接手了一个使用Appium进行自动移动测试的项目。我有一些应该与Appium一起运行的python脚本,但是当我尝试运行它们时,我遇到了“[INSTALL_FAILED_VERSION_DOWNGRADE]”。在对此问题进行了大量研究后,我发现这是一个与Android相关的问题,而且是APK版本。但是我是Android的新手,所以这使得完全理解Appium和Android正在做的事情具有挑战性。当我尝试将应用程序安装到设备时,我更倾向于解决问题,但是我觉得我已经解决了解决问题的步骤。一些例子是确保我有最新版本的应用程序,卸载应用程序,重新安装旧版本的应用程序,最后检查更新。
Python脚本追溯:
@
Appium控制台:
Traceback (most recent call last):
File "main.py", line 310, in <module>
launch()
File "main.py", line 26, in launch
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
File "C:\Python\lib\site-packages\appium\webdriver\webdriver.py", line 36, in __init__
super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 151, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 240, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "C:\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: A new session could not be created. (Original error: Command failed: C:\AndroidSDK\platform-tools\adb.exe -s GCNPCX031761JAV install "C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
Failed to install C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
)
更新:我重新启动计算机并再次运行它,它摆脱了[INSTALL_FAILED_VERSION_DOWNGRADE],但现在我正在
error: Failed to start an Appium session, err was: Error: Command failed: C:\AndroidSDK\platform-tools\adb.exe -s GCNPCX031761JAV install "C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
Failed to install C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
info: [debug] Error: Command failed: C:\AndroidSDK\platform-tools\adb.exe -s GCNPCX031761JAV install "C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
Failed to install C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: C:\\AndroidSDK\\platform-tools\\adb.exe -s GCNPCX031761JAV install \"C:\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk\"\nFailed to install C:\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]\r\n)","killed":false,"code":1,"signal":null,"cmd":"C:\\AndroidSDK\\platform-tools\\adb.exe -s GCNPCX031761JAV install \"C:\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk\"","origValue":"Command failed: C:\\AndroidSDK\\platform-tools\\adb.exe -s GCNPCX031761JAV install \"C:\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk\"\nFailed to install
C:\\Appium\\node_modules\\appium\\build\\settings_apk\\settings_apk-debug.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]\r\n"},"sessionId":null}
这似乎是ADB的权限问题。
答案 0 :(得分:4)
尝试adb install -r -d ${PATH_TO_APK}
。
答案 1 :(得分:2)
也许app没有正确卸载,请尝试运行命令:
adb shell pm uninstall com.xxx.xxx
将“com.xxx.xxx”替换为您的包裹名称。
答案 2 :(得分:1)
您遇到的第一个问题([INSTALL_FAILED_VERSION_DOWNGRADE])已在最近的Appium服务器版本 1.7.1 中修复,因此如果您使用的是最新服务器,则无需搜索解决方法。
第二个无法启动Intent的问题更像是您的Android应用manifext.xml
文件的问题,您可以检查它是如何修复的here
答案 3 :(得分:0)
以防万一,这对任何人都有帮助,我最近收到了此错误Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
,这是因为我已经在Android手机上安装了该应用程序,然后将分支切换到了较早的版本号并尝试安装该版本。
简单的解决方案,只需卸载应用程序并重新安装即可。