Speed up your Android Dynamic Features flow testing

with Gradle Play Publisher plugin

Marcel Pintó
Android Developers
3 min readDec 20, 2019

--

More and more Android apps are integrating Dynamic Features into their projects, although the fact that you need Play Store to deliver the features, makes it hard to test the real user flow (i.e user opening the app and installing a module after clicking somewhere).

Android Studio offers a way to select which Dynamic Features to include when running the app, although it doesn’t offer a way to test installation of the Dynamic Feature modules from Play.

Luckily, we have Play Internal App Sharing which allows developers to upload versions of the app and quickly and easily share it with others for testing.

This means that to test the full flow, we must: build a bundle, upload it to Play Console Internal App Sharing, copy the upload link, open it on a device, then install the app to try it out.

There is a better way.

With the new version of Gradle Play Publisher, we can automate the flow above in one click/command.

How?

First, setup Gradle Play Publisher:

  1. Upload the first version of your App Bundle using the Google Play Console
  2. Create a Google Play Service Account
  3. Grant access to your Play Console (Only the account owner can do that)
  4. Sign your release builds with a valid signingConfig (Required for release builds)

Next, add and apply the plugin to the root and base/app module build.gradle:

build.gradle →

app/build.gradle →

serviceAccountCredentials should point to the Json file that contains the key for the service account you set in Step 2.

defaultToAppBundles set this flag to true to tell the plugin to create app bundles by default (required for Dynamic features)

That’s it. You can run the “installReleasePrivateArtifact” from the console or directly from the Android Studio (Select it from Gradle tasks under app > publishing).

The tasks will build an App Bundle, upload it to Play Internal App Sharing, and launch the Play Store internal app sharing page, pointing all connected devices to the newly uploaded version.

You will still have to manually click into the update button and launch the app.

Using Debug or other variant builds

There is no task to upload debug or other variant builds yet (#619), thus if you want to use debug or any other variant builds you must configure the plugin a bit differently.

You have to set up the artifactDir and make the task depend on the bundle${Variant} task.

With this setup when running “installReleasePrivateArtifact” it will always use the debug variant.

Demo

In the video below you can see it working. We launch the task, since there was no change from the last upload (for shortening the video), the plugin automatically launches the last internal app sharing URL to the connected device.

--

--

Marcel Pintó
Android Developers

Android and Flutter expert, founder of https://pibi.studio a mobile experts hub for building apps and providing expertise. Other projects: https://namewith.ai