I am configuring my Android app to use Play Asset Delivery, using the install-time
option.
I am following the official guide found here
Here are my following configurations:
In the project setup, I have created an asset_pack directory, including the sub directories src/main/assets
In the app gradle I setup my asset pack:
assetPacks = [":asset_pack"]
In the settings.gradle I included my asset pack:
include ':app'
include ':asset_pack'
In the asset pack gradle I added the reference to the asset pack and method of download:
assetPack {
packName = "asset_pack"
dynamicDelivery {
deliveryType = "install-time"
}
}
Everything seems to be working fine until I try to retrieve assets from this root level directory.
The documentation states that I should be using this method:
val packageContext: Context = createPackageContext("com.example.app", 0)
val assetManager: AssetManager = packageContext.assets
val inputStream: InputStream = assetManager.open("basemap/phil.jpg")
My app crashes when trying to retrieve assets (I have replaced the com.example.app with my app info)
When I look up the assetManager list assetManager.list("")
files that show up are all part of the app package. Unfortunately, the folder named asset_pack or any of its content does not show up as an option.
Here is my question: I imagine that the reason why I am not seeing my asset_pack files is because it is at the same level at my app directory, but I don't know how to access that folder using the assetManager. Would anyone know how I access those files?
The correct answer can be found at How to access assets-pack data in Android (kotlin) Basically edit your run configuration to create the apk to be installed from the app-bundle