Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug my app in which OBB Expansion Packs have been replaced with PAD (Play Asset Delivery)?

Eager to retire our app's aging OBB Expansion Pack system and replace it with the shiny new Play Asset Delivery (PAD, formerly known as Dynamic Asset Delivery), I've been following the documentation. But I'm stumped as to what to do next. How do I get to a place where I can hit Debug and find the assets ready to go, like in the old days when my OBB was waiting in the phone at /storage/emulated/0/Android/obb/?

TLDR: My answer is below, but I would love it if there was a way to achieve speedy debugging with an install-time asset pack. The current workflow described in my answer requires 1) a wait of about 5-10 minutes to build the bundle, 2) build an APKS blob, then 3) install it from the splits.

Below is a record of my journey to understanding how to work with a ready-upon-install asset pack. I'm hoping that my account of my efforts will land some search hits from other confused developers and light their way.


HOW IT ALL STARTED

My goal: to achieve a situation as seamless as back when I would punch the Debug button in Android Studio, knowing the expansion back was snugly installed in the appropriate directory, to serve pictures and sounds to our app. Here I hoped to hit Debug and similarly find the pictures and sounds ready to use, but instead right at home in my Asset Manager.

In the tradition of the Expansion Pack docs, the PAD docs made --local-testing sound like a breeze. But then the trouble began.

So I first set up the very alpha v0.15 bundletool in hopes of experiencing "quick, iterative cycles" that would avoid having to upload to Play Store during development. So far so good! I used the --local-testing flag to generate a collection of APKs.

The confusion set in when I connected my device and ran the "bundletool install-apk" command. Bundletool says little, and didn't have much in the way of a -help screen. But it spat out these files:

ADB >> OK
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-xxhdpi.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-master_2.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-de.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-fr.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-nb.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-sv.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-arm64_v8a_2.apk" 

I thought one of them might be the name of my asset pack, "my_asset_pack.apk" or something like that. But none was.

So I was curious as to which of these files contains the assets I broke out into the asset pack separate from my base app assets. I recognized the localization strings ("de", "fr", etc.). But what about my non-localized media? (Could they be in base-master_2.apk?)

Was there more I needed to do to make these assets show up? So far my ready-upon-install assets didn't seem to be available from the Asset Manager on boot, so I must be missing a step.

EDIT: Updated to reflect name change from DAD to PAD.

like image 872
John Gorenfeld Avatar asked Jun 16 '20 11:06

John Gorenfeld


2 Answers

I don't know how it is in Android Studio but in Intellij IDEA you need to change "Deploy" option from "Default APK" to "APK from app bundle" in edit configuration window. With this option changed I was able to debug my app using app bundle without problems. enter image description here

like image 101
Bero Avatar answered Oct 21 '22 14:10

Bero


OK, so the big picture is that our command line is going to do the work that the Play Store would normally perform when receiving our bundle, churning it through the mill and publishing it in APK format. The bundle spits out a blob of split .APKs which are then, in turn, used to perform installation on our device.

INSTALLING YOUR DEBUG BUILD WITH ON INSTALL ASSET PACK

  1. In AS, go to "Generate Signed Bundle -> Android App Bundle."

  2. Build a debug build with your credentials.

  3. With Bundletool 1.0 or higher:

bundletool build-apks --bundle=./app-debug.aab --output=./my_app.apks --ks <path to my keystore.jks> --ks-key-alias=<keystorealias> --local-testing

  1. Use our .apks blob for app installation:

bundletool install-apks --apks=./my_app.apks

  1. Tap your newly installed app

  2. Run -> Attach Debugger To Android Process.

  3. Enjoy the presence of your assets right there in your AssetManager.

But have we achieved "quick, iterative cycles?" Eh, sort of. Takes maybe 10 silent minutes to build that blob on my Dell XPS under WSL. Maybe it's time to take out the checkbook for that 64-core Ryzen Threadripper.

DEBUGGING YOUR FRESHLY-INSTALLED DEBUG BUILD WITH ASSET PACK

Here's what works for me. Before building the bundle, I temporarily copy all the asset pack assets from </my_asset_pack_dir> into the normal base assets directory, /app/src/main/assets/. That way I can verify that the app can reach them through AssetManager. Then these temporary files could be ignored during build, or deleted by a script.

This way the assets can be tested without the 10 minute wait for .AAB -> .APKS -> split install.

like image 2
John Gorenfeld Avatar answered Oct 21 '22 16:10

John Gorenfeld