Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to manage debug and release version on android device?

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?

like image 248
Geob-o-matic Avatar asked Feb 10 '11 17:02

Geob-o-matic


People also ask

What is debug and release in Android?

Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.

How do I turn off debug mode on Android?

Go to Settings. Tap System > Developer options. Go to USB debugging and flip the switch to turn it off.


2 Answers

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"         }     } } 
like image 136
Evan Grim Avatar answered Sep 23 '22 18:09

Evan Grim


I'm not aware of any easy way to do get around the uninstall/reinstall process, so your options include...

  • Buy a second device for testing (some Android devices are very cheap now, especially on eBay)
  • Use the emulator for testing

I see the same issue, but it's to be expected, so I use the phone for debug dev, and the tablet for production testing. When I'm close to a release, I test the production version on both devices and the emulator.

With your testers, I'd advise that you always give them release versions, but you could include extensive logging to help with problems. Debug versions are then only used by you, and release versions by them. If you provide testers with a release version, they use, and accumulate data, when they come to upgrade to the next version, the data can be retained (or updated, if you change the schema) to migrate their data.

I don't see a need for your testers to be using debug & release versions.

like image 32
Ollie C Avatar answered Sep 25 '22 18:09

Ollie C