失败[安装失败版本降级]

2024-04-26 18:41:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近接手了一个项目,该项目正在使用Appium进行一些自动化的移动测试。我有一些python脚本应该与Appium一起运行,但是在尝试运行它们时,我遇到了“[INSTALL_FAILED_VERSION_degrade]”。在对这个问题进行了大量研究之后,我发现这是一个与Android相关的问题,它是APK版本。不过,我对Android还不太熟悉,所以要完全了解Appium和Android都在做些什么是很有挑战性的。当它试图将应用程序安装到设备上时,我更倾向于一个问题,但是我觉得我已经解决了解决这个问题的步骤。一些示例包括确保我拥有最新版本的应用程序、取消安装应用程序、重新安装较旧版本的应用程序,以及最后检查更新。

Python脚本回溯:

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]
)

Appium控制台:

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}

更新:我重新启动计算机并再次运行它,它摆脱了[安装失败的版本降级],但现在我得到了

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: An unknown server-side error occurred while processing the command. Original error: Error occured while starting App. Original error: Error executing adbExec. Original error: 'Command 'C\:\\AndroidSDK\\platform-tools\\adb.exe -P 5037 -s GCNPCX031761JAV shell am start -W -n com.rockfordfosgate.perfecttune/com.rockfordfosgate.perfecttune.activity.HomeActivity -S' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.rockfordfosgate.perfecttune/.activity.HomeActivity } from null (pid=10837, uid=2000) not exported from uid 10127
        at android.os.Parcel.readException(Parcel.java:1683)
        at android.os.Parcel.readException(Parcel.java:1636)
        at android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3352)
        at com.android.commands.am.Am.runStart(Am.java:630)
        at com.android.commands.am.Am.onRun(Am.java:388)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
        at com.android.commands.am.Am.main(Am.java:121)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:294)'; Code: '1'

这似乎是ADB的权限问题。


Tags: installinpydebugbuildmodulesnodesettings