153

I am currently trying to compile and test a small Android Application.

I am using Eclipse, and have SDK 4.2 (Api Level 17) installed. I've set

<uses-sdk android:targetSdkVersion="17" android:minSdkVersion="8" />

although I've tried also different values (i.e. 17/17).

I do not use any GoogleAPI functions, nor do I use functions that are not available in API Level 8. Or at least I do not get any compile errors or warnings in that regard.

When I compile the project and run it on a real device running Android 2.2.1 the Application runs fine. However when I try to run the application on an emulator (Android Virtual Device) with Android 4.2, Api Level 17 I get the following error:

[2012-12-10 21:10:29 - SoftKeyboard] Installation error: INSTALL_FAILED_VERSION_DOWNGRADE
[2012-12-10 21:10:29 - SoftKeyboard] Please check logcat output for more details.
[2012-12-10 21:10:29 - SoftKeyboard] Launch canceled!

Logcat however is empty. I have really no clue, what this error even means...

ndbd
  • 2,056
  • 3
  • 19
  • 29

16 Answers16

377

It means you're trying to install an app with the same packageName as an app that's already installed on the emulator, but the one you're trying to install has a lower versionCode (integer value for your version number).

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, either:

  • uninstall the currently installed copy

  • or open up your phone's Settings > Application Manager to determine the version number for the installed app, and increment your <manifest android:versionCode to be higher in the AndroidManifest.

  • or https://stackoverflow.com/a/13772620/632951

Community
  • 1
  • 1
Alexander Lucas
  • 21,031
  • 3
  • 43
  • 43
  • 1
    Thanks! It was exactly that - I exprimented with the Softkeyboard example from an older SDK, and it seems a Softkeyboard example is already installed (by default?!) in the emulator devices (but in a different, later version). After renaming my application everything worked as expected... – ndbd Dec 10 '12 at 23:19
  • Thanks...I was working with API demos and this application is always installed on emulators.. – Khushboo Jun 03 '13 at 11:09
  • 2
    @Alexander: Can you update this answer to include the -d flag? – David Alves Jul 15 '14 at 22:46
  • 8
    It is not needed to uninstall the app. Use flags: -r -d These flags mean reinstall and downgrade. – petrsyn Dec 19 '15 at 23:32
  • 1
    @petrsyn: where do I put these flags in Eclipse? – Violet Giraffe Dec 22 '15 at 12:00
  • 2
    @VioletGiraffe it is used in command line: adb install -r -d Application.apk – petrsyn Dec 22 '15 at 16:39
  • Downvoted as uninstall or version incrementing should not be necessary for every development installation. Try setting the explicit versionCode in AndroidManifest.xml (not resource: @integer/versionCode), then eclipse's play button (or run as->Android application) should work: https://stackoverflow.com/a/14946938/431296 Using a versionCode resource prevented installing even a higher versionCode apk for me. – Stan Kurdziel Jul 31 '16 at 04:58
  • @StanKurdziel: Not suggesting the versionCode should be incremented *every* time you install the app. Just that if you're trying to install a version with a *lower* versionCode than what's already on the device, you fix that by incrementing the versionCode to a higher value, once. – Alexander Lucas Aug 02 '16 at 19:52
  • Resolved this problem by running in Android Studio where it was able to prompt me if I wanted to delete the existing installation. On the command line it just threw and error but didn't prompt. – Michael Osofsky Jun 06 '17 at 19:34
  • Make sure to uncheck 'Preserve application data/cache on device between deploys' under `Tools -> Options -> Xamarin -> Android Settings: Emulator Device/Debugging.` – benscabbia Mar 13 '18 at 12:13
  • To fully uninstall the app from my phone, it was not enough to drag the app to the garbage can. I also had to go into Settings > Apps on my phone, find the app, tap the app, tap the "..." icon in the upper right corner of the "App info" page, and tap "Uninstall for all users". Then I was able to issue the `adb install` command succesfully. – Michael Osofsky Nov 08 '18 at 04:14
  • // List of packages `adb shell cmd package list packages` // Uninstall app `adb uninstall ` – Pavol Travnik Sep 30 '19 at 10:47
67

You can also consider adding -d flag to adb install. It should ignore this error.

adb install -r -d abc.apk
Pavel Chuchuva
  • 21,289
  • 9
  • 93
  • 110
gruszczy
  • 37,239
  • 27
  • 119
  • 167
31

First uninstall your application from the emulator:

adb -e uninstall your.application.package.name

Then try to install the application again.

user1719362
  • 344
  • 2
  • 3
  • 9
    Or for a connected physical device, `adb -s DEVICESERIALNUMBER uninstall your.application.package.name`, where `DEVICESERIALNUMBER` can be found using `adb devices -l`. – Joel Purra Nov 27 '13 at 10:24
  • Seems like an unnecessary step if you just wanna debug an application. – IgorGanapolsky Apr 08 '16 at 14:14
9

This was happening in my project because I was using an XML resource to set the version code.

AndroidManifest.xml:
android:versionCode="@integer/app_version_code"

app.xml:
<integer name="app_version_code">64</integer>

This wasn't a problem in prior versions of adb, however, as of platform-tools r16 this is no longer being resolved to the proper integer. You can either force the re-install using adb -r or avoid the issue entirely by using a literal in the manifest:

android:versionCode="64"
James Wald
  • 13,196
  • 5
  • 48
  • 63
  • This was the problem for me, and I agree it's not resolving the versionCode properly, even increasing it (ex: 65) doesn't avoid the INSTALL_FAILED_VERSION_DOWNGRADE – Stan Kurdziel Jul 31 '16 at 05:00
5

This can happen when trying to install a debug/unsigned APK on top of a signed release APK from the Play store.

H:\>adb install -r "Signed.apk"
2909 KB/s (220439 bytes in 0.074s)
        pkg: /data/local/tmp/Signed.apk
Success

H:\>adb install -r "AppName.apk"
2753 KB/s (219954 bytes in 0.078s)
        pkg: /data/local/tmp/AppName.apk
Failure [INSTALL_FAILED_VERSION_DOWNGRADE]

The solution to this is to uninstall and then reinstall or re run it from the IDE.

Community
  • 1
  • 1
Deanna
  • 22,939
  • 7
  • 65
  • 142
3

INSTALL_FAILED_VERSION_DOWNGRADE

All Android apps have a package name. The package name uniquely identifies the app on the device. If same packageName as app that's already installed on the device then this error Showing .

  1. You can uninstall the application from your device first and then install the fresh one .
  2. You could simply increase the number by one each time a new version is released.
IntelliJ Amiya
  • 70,230
  • 14
  • 154
  • 181
  • 1
    You are correct the versionCode must be increased on each release. However, not at development time before a release. Also, you should be able to install an apk with the same versionCode on top of an already installed apk (without uninstalling). My hunch is the problem was the resource referenced versionCode - see: https://stackoverflow.com/a/14946938/431296 – Stan Kurdziel Jul 31 '16 at 05:05
3

In Marshmallow, I got this error,

Installation error: INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE
Please check logcat output for more details.
Launch canceled!

Looking for solution I searched and came here. I deleted the app but still have this problem in Nexus 6. Later found that in,

Settings > Apps > [My app name] have to removed for all user. 
karim
  • 14,810
  • 7
  • 55
  • 92
2

According to sdk src code from ...\android-22\android\content\pm\PackageManager.java

/**
 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
 * the new package has an older version code than the currently installed package.
 * @hide
 */
public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;

if the new package has an older version code than the currently installed package.

zhijuexu
  • 199
  • 1
  • 5
2

I was having same problem. I was getting error when i tried to run in my android device not emulator.

sudo ionic run android 

I am able to fix this by running

adb uninstall com.mypackage.name
Anjum....
  • 3,545
  • 1
  • 30
  • 41
2

you can try this: adb install -r -d -f your_Apk_path

baiiu
  • 67
  • 5
1

this happened to me when I imported an Android Studio App into eclipse.

I figured out the andoridmanifest.xml file needs to be slightly modified when importing from android studio project. I created a new test project, and copied over the headings to make it match. voila, issue solved.

BrayNShock
  • 11
  • 1
1

This error appears in my android project with multiple kind of gfx files. At the end no change in the manifest file was accepted.

Because my lack of knowledge about the android devices I forget that my test device has a second User. This User also has an installed version of my app so I also have to delete the app for this user account and it works.

norca
  • 128
  • 1
  • 11
1

I was having the same problem. I installed with

    adb shell pm install --user <userId> test.apk

For some reason, there was no icon on the screen. It was a debug build and all other consecutive installs were not working. Simply uninstalling the package helped.

     adb uninstall com.package.name
0

the thing that kept on killing me was that i didn't know that this app was installed for my guest account (although I had uninstalled it for the other accounts..)

so i searched for the app in the app manager, and simply clicked on uninstall for all users

enter image description here

abbood
  • 21,507
  • 9
  • 112
  • 218
0

Just uninstall the previous Apk and install the updated APK

Peter
  • 380
  • 3
  • 11
0

It may be a problem with the Google Play Services dependencies rather than an actual app version issue.

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