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:

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

build.gradle →

repositories {

google()

jcenter()

maven { url "https://plugins.gradle.org/m2/" }

}



dependencies {

...

classpath "com.github.triplet.gradle:play-publisher:2.6.1"

}

app/build.gradle →

apply plugin: 'com.github.triplet.play' /* ... */ play {

serviceAccountCredentials = file("service-account-key.json")

defaultToAppBundles = true

}

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.

play {

serviceAccountCredentials = file(“service-account-key.json”)

defaultToAppBundles = true // Defines the path to Debug bundles

artifactDir = file(“build/outputs/bundle/debug”)

} afterEvaluate {

tasks.named(“uploadReleasePrivateBundle”).configure {

dependsOn(“bundleDebug”)

}

}

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.