Failure [INSTALL_FAILED_VERSION_DOWNGRADE]

0

I recently took over a project which is using Appium to do some automated mobile testing. I have a few python scripts that are supposed to be ran with Appium however when attempting to run them I run into "[INSTALL_FAILED_VERSION_DOWNGRADE]". After much research on the matter I have included that this is a problem related to Android and it's APK version. However I am new to Android so this makes it challenging to fully understand both what Appium and Android are doing. I am leaning more towards a problem when it is trying to install the application to the device, however I feel I had addressed the steps to troubleshooting that. Some examples are ensuring that I had the latest version of the app, de-installing the app, reinstalling an older version of the app, and finally checking for updates.

Python script traceback:

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 console:

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}

UPDATE: I restarted my computer and ran it again and it got rid of the [INSTALL_FAILED_VERSION_DOWNGRADE] but now I am getting

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'

Which is seeming to be a permissions problem with ADB.

android
python
apk
appium
python-appium
asked on Stack Overflow Oct 17, 2017 by Austin Efnor • edited Oct 17, 2017 by Austin Efnor

4 Answers

6

Try adb install -r -d ${PATH_TO_APK}.

answered on Stack Overflow Jun 13, 2018 by jetmc
4

Maybe app is not deinstalled correctly, try running command:

adb shell pm uninstall com.xxx.xxx 

replace "com.xxx.xxx" with the name of your package.

answered on Stack Overflow Nov 21, 2017 by edvard_munch
1

The first issue you faced ([INSTALL_FAILED_VERSION_DOWNGRADE]) was fixed in recent Appium server version 1.7.1, so if you are using latest server no need to search for workarounds.

The second issue of not able to start Intent is more like problem with your Android app manifext.xml file, you check how it can be fixed here

answered on Stack Overflow Nov 18, 2017 by dmle
0

Just incase this helps anyone, I recently got this error Failure [INSTALL_FAILED_VERSION_DOWNGRADE] and it was because I had installed the app on my android phone then I switched branch to an earlier version number and tried to install that.

Simple solution, just uninstall the app and install it fresh.

answered on Stack Overflow Jan 30, 2020 by Brad

User contributions licensed under CC BY-SA 3.0