127

It seems like the most recent Android 4.2 has introduced this error condition on installation when one attempts to install an APK with a lower version. In prior versions of Android, one would be able to install older APK's simply via adb install -r <link to APK>. For debugging purposes, I frequently need to re-test older APK's; and the -r flag would replace the older build in older Android versions. Is there a work-around here to ignore [INSTALL_FAILED_VERSION_DOWNGRADE]?

Jonik
  • 74,291
  • 66
  • 249
  • 356
AaronMT
  • 1,395
  • 2
  • 9
  • 6

10 Answers10

298

It appears the latest version of adb tools has an "allow downgrade flag" that isn't shown in the adb help, but it is shown in the "pm" help on the device. So use: adb install -r -d <link to apk>

supereee
  • 3,115
  • 1
  • 12
  • 9
  • 4
    Tried with `adb install -rd ` which didn't work. Your versino (with options separated) works fine. Thanks! – MarSoft Nov 22 '15 at 22:05
  • 1
    And it seems to be documented now! Just not that you have to use -r -d, -rd will not work – plaisthos Jan 08 '16 at 12:44
  • For example, to uninstall (downgrade) Waze 4.0.0.2 and install version 3.9.5.3: **adb install -r -d Waze_3.9.5.3.apk**. This way you won't lose app data. – Derek Gogol Mar 14 '16 at 19:06
  • 17
    Since Android 7 (Nougat), adb install -d no longer works unless the package is marked as debuggable. https://android.googlesource.com/platform/frameworks/base/+/921dd75 – Darpan Jun 18 '18 at 10:28
  • 2
    For me it worked when I did `adb install -t -r -d app.apk` – arekolek Oct 13 '20 at 06:53
  • @Darpan So for signed APKs, it's impossible to install older versions on top of new ones, right? – android developer Mar 01 '21 at 09:03
21

You can try and use adb uninstall -k <package> and then installing the older apk. From the adb usage guide:

  adb uninstall [-k] <package> - remove this app package from the device
                                 ('-k' means keep the data and cache directories)

I've tried it myself with my apk, and it seems to work for most of the data (some data like RawContacts was not saved)

Talihawk
  • 1,224
  • 9
  • 18
  • It appears that this command does not actually execute the uninstall, instead simply yielding a warning. The command to actually excecute this appears to be `adb shell pm uninstall -k `. – Paul Lammertsma Dec 23 '13 at 13:40
  • This is also useful for downgrading, if adb -d still complains as it did for me. – Pointer Null Apr 09 '15 at 21:45
16

Did you enabled Multiple account on your device (and push your apk via ADB)? If so you have to remove the apk in every account. After complete uninstall, your push will be OK.

OlivierTurpin
  • 270
  • 1
  • 4
  • Restoring backup via Titanium Backup did not work. Fresh install did not work. Installing via APK and/or adb install did not work. This cost me 1,5h and your simple tip did the trick. Thanks! – bentolor Sep 17 '17 at 09:02
  • This helped in the following situation: I uninstalled an app and restored an older version with Titanium Backup. After an automatic app update I tried to downgrade again with TB > hung up on restore; tried installing the APK manually > didn't work with the error "App not installed". So my take away is that TB falesly seems to install apps globally for all users. Samsung S9, Android 9. – sir_brickalot Sep 06 '20 at 12:54
3

In my case it was a stale version of Google Play Services included with my project. I am using Android Studio. I ran an update on the SDK, and imported the updated library, and that error went away. So my suggestion: update to the latest libraries that are referenced by your project.

IgorGanapolsky
  • 23,124
  • 17
  • 109
  • 132
1

I also faced the same problem.It can be resolved with below steps which are easier than deleting any apk from the device -

1) Run command "adb logcat | grep -i version" on the terminal

2) Look for the particular line, which will be shown at the end of the logcat -

"Downgrade detected: Update version code 5011  is older than current 9109"

3) copy the current version( for eg 9109) and paste it in AndroidManifest.xml as shown below -

android:versionCode="9109"

Now clean and rebuild the application and it should work fine.

Sunita
  • 1,159
  • 10
  • 16
  • 'grep' is not recognized as an internal or external command, operable program or batch file. grep is working on Unix like OS – leonidaa Feb 04 '21 at 09:13
1

Try uninstalling previously installed version of app using-

adb uninstall com.package.name

and then install/run your app again

Krishna
  • 3,949
  • 2
  • 24
  • 28
0

You might have installed from a separate copy of the code where the version number was higher than the copy you’re working with right now. In either case, uninstall the currently installed copy, or open up Settings > Apps to determine the version number for the installed app, and increment your versionCode to be higher in the AndroidManifest.

Ravindra
  • 19
  • 1
  • 1
    Why was this downvoted? It may not be the best answer, but it seems like a viable solution (and perhaps the easiest) for someone who is new to this! *Please* leave comments for answers like this, as they are *essential* not only for the answerer, but for the readers who visit this question later. :-| – jedd.ahyoung Jan 08 '14 at 02:21
  • This is of course something that can be done. It is obvious already. The question is asking if there is a way to skip this check and allow downgrade. And the answer is yes. This answer basically says no. – tasomaniac Jan 11 '17 at 08:59
0

It may be a problem with the Google Play Services dependencies.

Sometimes, it is NOT the case that:

a) there is an existing version of the app installed, newer or not

b) there is an existing version of the app installed on another user account on the device

So the error message is just bogus.

In my case, I had:

implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'

But when I tried

implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'

I got androidX related errors, as I had not yet upgraded to androidX and was not ready to do so. I found that using the latest 16.x.y versions work and I don't get the error message any more. Furthermore, I could wait till later when I am ready, to upgrade to androidX.

implementation 'com.google.android.gms:play-services-maps:16.+'
implementation 'com.google.android.gms:play-services-location:16.+'
implementation 'com.google.android.gms:play-services-gcm:16.+'
auspicious99
  • 2,413
  • 1
  • 26
  • 40
-1

In my case:

Step 1: Run

yarn start --reset-cache

Step 2: Run

yarn android
Dharman
  • 21,838
  • 18
  • 57
  • 107
Hai Dinh
  • 993
  • 2
  • 10
  • 24
-4

For people facing issues with Xiaomi:

adb shell pm uninstall <package_name>
Vaigunth
  • 250
  • 4
  • 11