Android: How to Have Multiple App Versions on Your Devices

Just like the Android design and usage patterns, the development for the platform is going through some significant changes. The Google engineers revealed at last year's Google IO Android Studio, an IntelliJ-based IDE specialized for developing Android applications. But not just the IDE was a big upgrade over Eclipse. It also integrated a new build system: Gradle.

Gradle Is Powerful

No question, Gradle has a learning curve and you'll need some time to get used to it. Google's documentation isn't super extensive but definitely helpful and a great start. It includes a short guide about build types, product flavors and the resulting build variant.

If you have an app which includes different versions, for example a free and a pro version, it's worth a look. You can have one project which includes and compiles both variants. This is mainly done by having different resource folders and merging them during the building process. For details, please review the section in the guide. But one positive side effect isn't mentioned.

Gradle's BuildType's applicationIdSuffix

The functionality is related to compiling the code for different versions. But what if you only have one version? Even then you can get some use out of Gradle. You can use applicationIdSuffix to create a different package name.

For example your Gradle script could look like this:

    android {

    [...]

    buildTypes {
        debug {
            debuggable true
            runProguard false
            zipAlign false
            applicationIdSuffix ".debug"
        }

        release {
            debuggable false
            zipAlign true
            signingConfig signingConfigs.releaseSignConfig
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
        }
    }
}

This overrides the default configuration of your debug and release version. You usually would use your release build type to create an APK for publishing on Google Play. The debug build type makes it easier to attach an debugger and doesn't officially sign and obfuscate the APK. The applicationIdSuffix adds an '.debug' to your package name, for example:

  • Release: com.futurestudio.foody
  • Debug: com.futurestudio.foody.debug

Does That Have Any Use?

Yes! It allows you to have both versions, release and debug, of the app installed at the same time! Remember, Android doesn't permit to install different apps with the same package name. With this small Gradle function, you can have both installed at the same time. You can do comparisons and validate that you didn't break anything with your new feature.

Another use case is related to the beta-testing feature of Google Play. If you are using the alpha, beta and release stages, you — as a developer — could have all versions on your phone if you utilize the applicationIdSuffix command.

Limitations

Unfortunately, this does not apply for your testers. Google Play does not allow you to upload an alpha or beta version with an attached .alpha to the package name. Your testers have to decide for one version.

Another technical limitation, at least at the moment, is that it can break some things. We have the problem that it breaks the SearchView. If you've a solution, please let us know!

Explore the Library

Find interesting tutorials and solutions for your problems.