Search code examples
androidcode-signing

How to install and run from Android Studio after installing from Play Store?


I have one app in the Play Store that I want to update. It's installed on my device currently, and I remember that I downloaded it from the Play Store a while back (to test that process). Now I'm trying to work on a new version, but I can't run my app anymore from Android Studio. I get this:

The device already has an application with the same package but a different signature. In order to proceed, you have to uninstall the existing application.

My app has local data and I don't want to wipe it out. I need to make sure my new version works with the previous version's data, so it's important to update code without a complete reinstall.

What do I do here? I don't have a ton of Android experience yet. I coming from iOS world where this doesn't happen. I can always update the binary from Xcode, whether the current version came from the store or not.


Solution

  • Your app in the Google Play Store is signed with a signing key. Most likely, you created a new keystore specifically for the release version of your app.

    On android, if you want to update an app, the following criteria must be met:

    1. The application ID of the new version is the same as the application ID of the old version (otherwise the new version is considered a new app)
    2. The new version must be signed with the same signing key as the previous version.

    Android Studio will automatically create and use a signing key for debug builds of an app. If you want to install your debug version on top of your store version in order to test an update, you will need to change the signing key for the debug version.

    Add this signing information to your app module's build.gradle file. Replace all the information (alias, passwords, file location) with the actual credentials and information for your release signing key:

    android {
    ...
    
        signingConfigs {
            debug {
                keyAlias 'debug'
                keyPassword 'debug123'
                storeFile file('../signing/identityDebug.jks')
                storePassword 'debug123'
            }
        }
    }
    

    What If you don't have your release signing key anymore?

    You're out of luck. You won't be able to update your app anymore. Uploads to the Google Play store with a different signing key will fail as well.

    If your app only stores data in the external directories, you can access it with a file browser. Access to the internal storage is only possible on rooted devices.