Posted on

Android How To Install Debug/Release Versions Simultaneously


android debug release install simultaneously

Designed by Freepik

 

I was thinking about sharing this tip where you can have debug/release apps installed simultaneously on your phone. It helps in few aspects, let’s look at that

Why

By default you can have only one version of your app installed, by actually having several of them is super useful

For example you have released your app on Play Store and working on a next version. It’s super handy to go and look at what your production app looks like sometimes or just to test it without having to uninstall your debug version for it

Application ID

If you try to install release version while debug is installed you’ll get a message saying that you have this app installed already. And vice versa

So the only thing stopping you from having multiple versions installed is applicationId. You just need to have different ids for different versions in your app’s build.gradle

Here debug version will have com.myhexaville.sample.debug applicationId and release com.myhexaville.sample

That’s all you need to do. Now you can enjoy having several app versions installed on your phone simultaniously

Different Icon

Although they’d look exactly the same. You need to distinguish them at least some how

The perfect solution is to make a different icon. I think turning icon into blank ‘n’ white is perfect for debug verison

Using your favorite image editor software make gray scaled icons and put them into app/src/debug/res folder

android debug release install simultaneously

Different Name

If you want to go further and append debug at the end of app’s name – super easy. By default you have a label string set in manifest referring to app_name strings resource

Create a debug version of strings.xml in app/src/debug/res/values folder and declare different app’s label

android debug release install simultaneously

Google Services

Remember when I said you don’t have to do anything but add applicationIdSuffix for debug build type? If you have google services in your app, which is very likely – you need to do one extra thing

This google-services.json file that you put in app folder, you need to create a copy of it and replace package_name with your debug application resulting id

Then put this newly created google-services.json file to app/src/debug folder

And your original google-services.json move to app/src/release

Now you won’t have anything in the app folder itself, but everything will be working perfectly

Extra Mile

I hope you’re exited about the stuff above. Now are you ready for an extra mile to make your app development totally dope?

Here’s the situation: you have multiple git branches, you switch between those. Have some features in feature_one branch, but they haven’t made it to the master branch (release)

Now you’re working on develop branch, feature_one has been abandoned for few months, you’re discussing with your coworkers about the awesome features your wrote in feature_one branch, but this version is not on your phone!

Even if you created a different application id for debug/release build types – you still can have only one debug version installed. Yes, you can also create different ids for product flavors, but they do not represent features in development, git branches do

So how cool would it be for debug builds have different application ids depending on current branch and release build just have your default application id? Very awesome or very awesome?

You could do it all manually by creating different product flavors with different application ids for each branch each time and switch between flavors each time you switch a branch. But as software developers – we hate manual work, we automate it

Gradle

And we’re going to use Gradle. If you don’t know a single thing about it besides how to add dependencies – I recommend check few of those posts after your finish reading this post

Look at how simple it is!

That’s all you need to do! Of course you need to have git initialized for your project. And now all your debug versions will have .debug.branchName appended at the end of application id. Which means you can have multiple debug app versions installed as well and it’s all totally automated!

Now when you want to show the cool stuff you wrote in feature_one branch a while ago – you don’t need to seek for Android Studio to build apk or keep that apk somewhere in the cloud – it’s always on your phone

Different App Name

And of course for a different branch you need a different app name. Here’s a Gradle task that runs on each build

Just add it at the bottom of your build.gradle. And here’s what I got

android debug release install simultaneously

First two apps are debug versions and last one is release with application ids as follows:

  • com.myhexaville.recycler.debug.master
  • com.myhexaville.recycler.debug.develop
  • com.myhexaville.recycler

I decided to have just branch name because appending at the end or beginning doesn’t work well even with such a short app name. And most likely you don’t have this default Android icon so you can recognize it easily without the name itself

 

Alright, let me know what you think about those tweaks. And don’t forget to subscribe!