Jump to content
Hans♫

How to deploy a large Android app (150+ MB) using "Play Feature Delivery"?

Recommended Posts

Our Android App is rejected by Play Store because it exceeds the 150 MB limit. It is not an option to make it smaller as it includes a large 170 MB file with audio samples, which is required by our app. 
The way to handle large app is to use the "Play Feature Delivery" option:  https://developer.android.com/guide/playcore/feature-delivery

 

However, the instructions to use the "Feature Delivery" is highly tied up on having a project in Android Studio. We could probably do it by setting up a dummy app in Android Studio, but I guess it will take some time without any knowledge about Android Studio.

Anyone having found a way to deploy a large Delphi app to Play Store?

Share this post


Link to post

Can you download these audio samples after installation from your server(s)? The same way as offline maps are downloaded by apps... And probably stored to SD cards instead of internal storage (user is asked where to store them).

  • Like 1

Share this post


Link to post
13 hours ago, Dave Nottage said:

Yes

Hi Dave,

Thanks, and of course I should have checked your Kastri library of additional implementations. I guess I didn't find it because I was only searching for "Play Feature Delivery", and not for "Play Assets Delivery", which Google describe as being ONLY for games. However, having read more details about it, I think it matches our needs perfectly well.

So I'll look further into your demo.

Share this post


Link to post

Hi Dave

I've managed to successfully build and install the AssetDeliveryDemo. Building/deploying the Android 64bit Release Application Store target with Asset Packs (Build.. and Install using the Codex 1.5.1 Tools) using our own keystore.

 

However, when running the AssetDeliveryDemo App on the device, only an empty startup screen is displayed, e.g. I don't see any Assets (expecting 3 video files). I've investigated the system log and see 
  info "FMX: AssetDeliveryDemo: Asset pack: ondemand_assetpack required space: 2MB..."
  info "FMX: AssetDeliveryDemo: Asset pack: fastfollow_assetpack required space: 1MB..."

Meaning the AssetDeliveryAssetPackStateUpdateHandler is called with TAssetPackAction:TAssetPackAction.Query for both the fastfollow and ondemand asset packs 
However, no further calls are coming thru to the AssetDeliveryAssetPackStateUpdateHandler.

 

Further I've investigated the app filesystem and in the base directory there's an "split_installtime_assetpack.apk" asset pack with the other split apks etc., but the content (video file) has not been extrated to /files as expected.
I've tried calling the FAssetDelivery.GetAssetPackPath('installtime_assetpack'), however, it only returns an empty string since FAssetPackManager.getPackLocation is nil

 

For our app we only interested in using the installtime asset, so I've incorporated this in our app and building that asset into our bundle and get the same results. Meaning the "split_installtime_assetpack.apk" is placed in to base directory and contains the asset, but it's not extracted.
Note, I've tried both building the app bundle with the automatic (codex) tools and manual scripts 

 

This version of the app bundle has also been uploaded and installed from Google Play Store to test if it was only a problem in local-testing mode, but the result is the same.

 

My Configuration
RAD Studio 11 Patch 1
Android SDK \Embarcadero\Studio\22.0\CatalogRepository\AndroidSDK-2525-22.0.42600.6491\platforms\android-30
NDK \Embarcadero\Studio\22.0\CatalogRepository\AndroidNDK-21-22.0.42600.6491\android-ndk-r21
Java tools from Android Studio 2020.3.1 Patch 3

Edited by Hans♫

Share this post


Link to post
20 hours ago, Hans♫ said:

However, when running the AssetDeliveryDemo App on the device, only an empty startup screen is displayed

While experimenting with the code (or for some other reason) it seems I had not reverted the code to use the Fetch method (which was commented out) rather than Query (in the IdleMessageHandler). Can you check whether changing this works for you?

 

Share this post


Link to post

Hi Dave,

 

Thanks for your reply, it's greatly appreciated.

Now Video1 and Video3 get downloaded when adding the call to FAssetDelivery.Fetch in the IdleMessageHandler. So the fast-follow & on-demand delivery modes both work correctly. And the videos are playing as well.

 

However, the install-time asset Video2 still does not show up. But I wouldn't have expected that the above fix would have solved that either. You write in the code:

//!!!! Install time packs are just "normal" assets

Do you see Video2 showing up in your app?

 

Maybe I'm wrong but as I read the android developer documentation the install-time asset pack will be available immediately at app launch, but that's only the apk and you need to access the assets in it thru the AssetManager API. See this diagram

 

I assume the solution in our case could be to use AssetManager API stream interface to make a copy of the file in a temporary location.

Do you agree?

 

Thanks again for your help!

Share this post


Link to post
3 hours ago, Hans♫ said:

you need to access the assets in it thru the AssetManager API.

That's correct. I have a method in TAssetDelivery called GetAssets that will enumerate them (note: this also enumerates any folders contained in the assets) at the top-level by passing a blank value for the path.

 

As per the AssetManager docs, there are methods for accessing the files, however as you may notice from those docs these are not methods that you can use in a traditional Delphi-like manner.

 

One way around this could be to use the open method of AssetManager to return an InputStream and (ultimately) save it to a file that can be accessed using traditional file methods, however it seems a bit of overkill - you might as well use a fast-follow pack.

 

If you're playing videos, you could re-write TMediaPlayer (or at least the Android part) to deal with assets accessed via AssetManager however I'm yet to find a way of using these in a VideoView that works.

 

 

 

Share this post


Link to post

Thanks Dave!

To achieve the best user experience we would like to use the install-time assets. We need to extract a 150 MB binary file to be accessed using traditional file methods, and had hoped that your demo app also supported install-time assets. As you mention, the only part missing is to extract and save the file using AssetManager.

Any chance that this could find it way into your demo project?

Edited by Hans♫

Share this post


Link to post
On 12/14/2021 at 2:14 AM, Hans♫ said:

Any chance that this could find it way into your demo project?

Whilst searching for something else, I came across this reply. If you haven't implemented this yet, I'll take a look.

Share this post


Link to post
On 6/16/2023 at 12:12 AM, Dave Nottage said:

If you haven't implemented this yet, I'll take a look.

Thanks for your kind offer. We managed to solve it on our own, and have used it for a while now. 

  • Like 1

Share this post


Link to post

With the new API 34, it looks like the solution we made for install time assets, based on the Kastri example, no longer works.
When installing the resulting .aab on a device (Google Pixel8) running Android 14 it throws an security exception and the Install Time asset isn't loaded:
  java.long.SecurityException: com.<applicationname>.android:
  One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts


As far as I see, the problem is the play-core-1.10.0.jar (February 2021) is no longer accepted.
And we need to migrate to the new Play libraries (since April 2022)
https://developer.android.com/reference/com/google/android/play/core/release-notes
Specifically the Play Asset Delivery Library - Latest update 2.2.2 (May 2024)
https://developer.android.com/reference/com/google/android/play/core/release-notes-asset_delivery

 

Anyone having experienced the same?

Share this post


Link to post
8 hours ago, Hans♫ said:

Specifically the Play Asset Delivery Library - Latest update 2.2.2 (May 2024)

As far as I can tell, you just need to switch from using play-core-1.10.0.jar to asset-delivery-2.2.2.jar. If that's not the case, let me know.

asset-delivery-2.2.2.jar

Share this post


Link to post
13 hours ago, Dave Nottage said:

you just need to switch from using play-core-1.10.0.jar to asset-delivery-2.2.2.jar

It might be a simple task for some, but at least not for me 🙂 

First step of the switch is to create a Delphi interface to the new jar, and next step is to make the code work with that interface and jar.

 

With the current solution we used the interface to play-core-1.10.0.jar, that you created and supplied in your Kastri example project. I made a quick attempt to do the same myself for asset-delivery-2.2.2.jar, using Java2OP.exe and the instructions supplied by Embarcadero - but unsuccessful. I believe this is just the first problem, out of many, to complete this switch of jar's. Probably because I have no idea what I am doing... So I won't list the error messages here to start a problem solving session.

 

I think it is more beneficial for the Delphi community if its solved by a competent person and shared with the community - and I'll be pleased to pay for the work, even if its shared.

Share this post


Link to post
6 hours ago, Hans♫ said:

First step of the switch is to create a Delphi interface to the new jar, and next step is to make the code work with that interface and jar.

I have done a more detailed check now (I had not when I sent the first message), and I can see that the classes/methods are all compatible and the namespacing of the classes is identical, so removing the old jar from the project and adding the new one should work, but I'll know for sure when I do a test, hopefully before the end of the weekend.

 

Share this post


Link to post
On 6/22/2024 at 5:27 AM, Dave Nottage said:

I'll know for sure when I do a test, hopefully before the end of the weekend.

As far as testing goes, so far this has not progressed well - the build process has changed which means the automation in Codex has broken, as well as the BuildBundle batch file that is provided with the demo. More later...

  • Thanks 1

Share this post


Link to post
On 6/23/2024 at 10:05 AM, Dave Nottage said:

More later...

Hopefully all sorted now, including:

  • Added new API import DW.Androidapi.JNI.AssetDelivery.pas
  • Added new jar files to the ThirdParty\Android folder in Kastri
  • Updated DW.AssetDelivery.Android.pas
  • Updated the demo, including the manifest template.
  • Updated the batch files which are included with the demo, to account for the changed Android build process in Delphi 12.1
  • Updated Codex to also account for the changed Android build process in Delphi 12.1

As you may have guessed, it wasn't as simple as swapping the .jar file, especially since asset-delivery-2.2.2.jar is dependent on play-core-common-2.0.3.jar. Newer versions of Android also require this implementation to have the Foreground Service Data Sync permission.

 

I am yet to test with an AAB that's actually on Play Store (whether internal or not), but "local" testing worked OK.

  • Like 1
  • Thanks 1

Share this post


Link to post

Thank you so much 👍

We have successfully incorporated your new solution in our project (we use our own build script). It has also been tested on Play Store and that works too!

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×