alex
alex

Reputation: 1260

Android Studio Installation failed since the device already has a newer version

We have written a new version of an Android app to upgrade an old one, but would like to extract login username from old apps SharedPreferences on first run after upgrade before overwriting the whole thing with the new data model. build.gradle of the new codebase specifies a newer versionName and versionCode, yet when we try to run from Android Studio onto a device that had the old app installed we get a dialog box with the following error message:

Installation failed since the device already has a newer version of this application.
In order to proceed, you have to uninstall the existing application.

WARNING. Uninstalling will removed the application data!

Do you want to uninstall the existing application?

[OK] [Cancel]

Obviously if we accept it uninstalls the old app along with all the user data and we cannot achieve what we intended.

Cannot find anything on the internet regarding this problem

error message

OLD APP build.gradle:

versionCode 1
versionName '1.4.1'

NEW APP build.gradle:

versionCode 2
versionName '2.0.0'

Upvotes: 7

Views: 12587

Answers (6)

Nishant Salhotra
Nishant Salhotra

Reputation: 71

In my case, I had multiple users on my device. The app got installed for all users. So I had to delete it for all of them.

Upvotes: 0

psx95
psx95

Reputation: 1

As it was mentioned in one of the comments above, it is purely because of the versionCode in the build.gradle I too had the same issue. My old app had a version code of 7009 and the new one had 7010. However, the old app's version code was changed during build-time (7009 was just the base-apk code) so as soon as I changed versionCode to 17010 which was much greater than 7009, I could install the new app over the previous one without uninstalling.

To confirm, maybe just try Logging the versionCode in console from the old app and make sure that the new version code is greater than that.

Upvotes: 0

alex
alex

Reputation: 1260

Ahh it looks like some gradle script from the old developers was overwriting the versionCode at build time with a much higher number... but now using a really high number I get INSTALL_FAILED_UPDATE_INCOMPATIBLE instead! :(

Upvotes: 0

mujjuraja
mujjuraja

Reputation: 359

@alex, Update "versionCode" ,"version name" in build.gradle. after complete clean proj and rebuild. Many time old all data not remove.

Upvotes: 0

guipivoto
guipivoto

Reputation: 18677

I believe this error is happening because your old APP has a higher versionCode than your new app.

So, you must update versionCode from your new app to a higher (or at least equal) value if compared to your oldAPP.

In the new app:

build.grade

android {
  ...
  defaultConfig {
    ...
    versionCode 2
    versionName "1.1"
  }
  ...
}

If your oldVersion was built in Eclipse, versionCode was probably defined in AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="string"
      android:versionCode="integer"
      android:versionName="string"
        . . .
</manifest>

Upvotes: 2

Anandroid
Anandroid

Reputation: 403

For testing you can change the version code to the one currently installed in the device.

Upvotes: 0

Related Questions