how to manage debug and release version on android device?

Geob-o-matic picture Geob-o-matic · Feb 10, 2011 · Viewed 7.5k times · Source

I'm new to Android dev and I'm almost ready to release a first version of my app :)

While testing the signed release apk on my phone, it refuse to install because the debug version is installed with the debug signature.

So I have to uninstall the debug version but it delete all my database (and it will do it to my friends who are testing it).

Is there a way to manage a debug and a release version of the same app without losing data?

Answer

Evan Grim picture Evan Grim · Apr 2, 2014

Many Android projects are starting to use the gradle build system (we transitioned to it when we started using Android Studio). Fortunately, gradle makes it really simple to install both a dev and release version simultaneously, each with their own independent data. The Android docs cover this, just add a applicationIdSuffix to your debug build type like so:

android {
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
    }
}