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

6

7

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'
Hacienda answered 15/7, 2016 at 12:15 Comment(2)
You must update "versionCode" in build.gradle. New version should have a higher (or equal) versionCode if compared to oldVersionBotchy
It would be very useful to just ignore this check. While deving, we probably know what's going on.Basically
B
2

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>
Botchy answered 15/7, 2016 at 12:21 Comment(2)
i repeat..."build.gradle of the new codebase specifies a newer versionName and versionCode"! Old app: versionName 1.4.1 and versionCode 1 New app: versionName 2.0.0 and versionCode 2 Clearly the opposite is true, which is why I was so dumbfounded by this error messageHacienda
Hi Alex. Sorry.. could you please update your question with build.gradle from both versions? Only difference is versionNumber?Botchy
W
0

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

Waistline answered 15/7, 2016 at 12:21 Comment(0)
M
0

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

Moia answered 15/7, 2016 at 12:22 Comment(0)
H
0

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! :(

Hacienda answered 15/7, 2016 at 13:3 Comment(0)
L
0

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.

Lark answered 1/2, 2019 at 20:52 Comment(0)
C
0

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.

Coagulate answered 5/11, 2020 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.