Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 488
alex Avatar asked Jul 15 '16 12:07

alex


1 Answers

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>
like image 182
W0rmH0le Avatar answered Oct 31 '22 16:10

W0rmH0le