zetbaitsu / PlayFeatureDelivery

Sample app to demonstrate Google Play feature delivery in Android using Buck and Gradle build tool system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PlayCore API sample

This sample demonstrates usage of the PlayCore API with gradle and buck build tool system.

Read more at http://g.co/androidappbundle

Introduction

The sample contains several modules.

app -> Contains the base application which always will be installed on device.

The MainActivity class demonstrates how to use the API to load and launch features.

The BaseSplitActivity abstract class implements the required SplitCompat.Install() call in the attachBaseContext method. This allow to launch an activity from a freshly downloaded dynamic module without having the restart the application.

features/* -> Contains features which can be downloaded on demand using the PlayCore API.

Each feature has some distinctly unique characteristics.

  • features/kotlin -> Feature written in Kotlin and will be available on-demand
  • features/java -> Feature written in Java and will be available on-demand
  • features/native -> Feature written in Kotlin using JNI and will be available on-demand
  • features/initiallInstall -> Feature written in Kotlin and will be available at install-time

The AndroidManifest files in each feature shows how to declare a feature module as part of a dynamic app.

Screenshot

Build project with Gradle and Buck

Build command Output Path
Gradle ./gradlew bundleRelease app/build/outputs/bundle/release/app-release.aab
Buck ./buckw build //app:bundle_release buck-out/gen/app/bundle_release.aab

Testing dynamic delivery

To test dynamic features locally use bundletool and follow the below steps:

  1. Build bundle file as mentioned in Build project with Gradle and Buck section
  2. Build apks file: bundletool build-apks --local-testing --bundle=<path_to_aab> --output=<path_to_apks> Make sure to include --local-testing flag
  3. Connect to the device/emulator
  4. Install apks: bundletool install-apks --apks=<path_to_apks>

This will generate and install multiple apks on the connected device. Note the difference between the buck and gradle generated apks. The gradle is generating extra apks for dynamic features as follows, which buck is currently not supporting:

Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/initialInstall-xxhdpi.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/initialInstall-master.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/java-xxhdpi.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/java-master.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/kotlin-xxhdpi.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/kotlin-master.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/native-xxhdpi.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/native-master_2.apk"
Pushed "/sdcard/Android/data/com.sample.buck.playfeaturedelivery/files/local_testing/native-x86_2.apk"

The generated aab from buck contains only base module:

.
├── BundleConfig.pb
└── base

About

Sample app to demonstrate Google Play feature delivery in Android using Buck and Gradle build tool system.

License:Other


Languages

Language:Starlark 60.3%Language:Kotlin 24.6%Language:Shell 11.9%Language:C 1.8%Language:Java 0.9%Language:CMake 0.4%