How to test your In-app updates in Android
Google provides a feature in the Play Core library to prompt apps users to install a more recent version directly within your app.
Be it flexible (not mandatory) or immediate (mandatory), this feature enable the developper to encourage users to stay up to date with the versions or can even compell the user to update before using the app in case of breaking changes.
A few requirements to use this feature:
- A device running Android 5.0 (API level 21) or higher,
- Use Play Core library version 1.5.0 or higher
First things first, there is a bit of code to write on the app before being able to provides this feature.
For a straight forward implementation, we can follow the tutorial from Google: https://developer.android.com/guide/playcore/in-app-updates
Now that our app is ready to ship with this new feature, we ‘d surely like to test how it works in our app’s navigation flow.
Since Play Core is required, we cannot build the debug app from the Android Studio emulator. To avoid directly shipping in production, we can use internal testing in the google play console.
We will create 2 test releases versions of our apps. Both should have the code to trigger an in app update.
First, we log inhttps://play.google.com/console/u/0/developers and select our app
Build an apk or app bundle anyway you want (through our CI, in Android Studio, etc.)
We go to internal testing, create a new release, import our app with let’s say version 26 and finally follow the flow to save our release.
We create a new release with version 27 for example (anything as long as it’s greater than the previous one)
Once we have our 2 test releases, we need to register testers for these releases.
In the same page, click on Testers. Create an email list with any one you want.
On the same page, there is a link in the How testers join your test section. We copy and keep it. we will need later.
In App bundle explorer section, let’s click on the Downloads tab, we copy the shareable link for both releases (we can switch versions in the upper right of the page)
The experiment was with an Android emulator but it should work with a real device I reckon.
We prepare a virtual android device in Android Studio with Google Play installed.
- login with one of our testers email in google Play Store
- enable internal app sharing in the parameters of google Play Store (enable developpers version of Play store and enable internal app sharing)
Everything is ready.
We navigate with the phone’s web browser to the link for testers.
Next, we copy a link to the oldest version of our app in the browser again. It should be something like https://play.google.com/apps/test/com.yourapp.package/26
Open the link and install the app. Our app is now installed through Play store and not with Android Studio.
Google is aware we downloaded the app and checked if a newer version was available. It even warns us during the install that this is an old version.
Finally, we kill the app installed with version 26 and launch it again. It can take a few minutes but the app will trigger your code to in app update the most recent version.
We can now test our navigation flow with this new feature. It’s not straight forward to test because of the play core dependency. Once the app was tested and approved, the release can be promoted to close, open testing or production.