Implementing and testing In-App update in android

Vignesh kumar
Jul 8 · 3 min read

Hi there, Android recently released In-app update feature and this is most awaited one. You may think, why we need to consume this API instead of doing it on our own? Yes, we can do this manually by redirecting the user to Play store with some business logic to update the app. But our customer can also skip it. In-app update API gives us more controls.

It helps when we rolled out an app with a bug and waiting for people to update manually from play store who turned-off Auto-update. The update may have some major Bug fix, Performance improvement, New feature. We can’t say all of our users know’s updating the app will improve their user experience, so it’s our duty to inform our users to update the application now google gave us an opportunity to do that. This article covers how to set up in-app update and how to test it.

How will it work?

When you new release the update, All of your users will get a prompt to update the app. Prompt can be blockable (Immediate) or non-blockable (Flexible). Flexible as the name says it will not force the users to update they can also use the app by close this popup, Immediate mode asks the user to update the app right away and the user cannot do any other action.

Our action plan, We gonna use In-app Android API and Firebase config in this example. The purpose of the Firebase config here is to set update type on demand.

Let’s code,

Step 1.

Setup Firebase config add dependencies, set default values and before this, you have to create a project in Firebase and add Google-services.json file into your project and new parameter app_update_type and assign value to it.

Flexible = 0, Immediate = 1

create an XML file with default values makes you adding it in XML directory under res.

set cache refresh time and at max cache can be refreshed 5 times in an hour and set default values

Step 2

In the previous step, we have configured firebase config now we are going to add App update prompt logic.

After releasing an update we can change app_udpate_type to 0(Flexible) or 1(Immediate) from Firebase console. When users open the app next time firebase config values will be refreshed and based upon the value prompt will be shown in our app

Let’s see how it works

Generate a release version with a lesser value than your market version. eg If your live version code in 21 then, generate release version with a version code of 20.

Uninstall your app if you have downloaded it from play store then install the app with in-app update changes with version code-20. That’s it Just open the app it will show in-app update Flexible prompt as because we specified 0 in Firebase config now go and change it in Firebase console to 1 and kill the app and open again it will show an immediate update prompt.

Troubleshoot :

Goto play store -> My apps & updates. let it check for any update availability. Now go to your application it will in-app prompt.

Reference: https://developer.android.com/guide/app-bundle/in-app-updates#kotlin

Thanks for checking out this article, please like and share ☺.

    Vignesh kumar

    Written by

    Software engineer

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade