4

I have a .NET MAUI Project with a lot of assets (images) in the Resources\Images directory that shall be deployed to the Google Play Store. This means that the size of the generated aab package is way beyond the Google Play Store limit of 150MB. (Message: Your App Bundle contains the following configurations where the initial install would exceed the maximum size of 150 MB...)

My current solution resizes the images to <= 150MB. I now saw that there is the possibility to generate separate files for the assets, which is called Play Feature Delivery.

From this sample project I get the following gradle file to create an install-time-package:

apply plugin: 'com.android.asset-pack'

assetPack {
    packName = "install_time_asset_pack" // Directory name for the asset pack
    dynamicDelivery {
        deliveryType = "install-time" // delivery mode
    }
}

My question is: Can this somehow be done with .NET MAUI? Is it possible to add some elements to the csproj-file to do this, just like for example for the keystore:

<PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">
    <AndroidKeyStore>True</AndroidKeyStore>
    <AndroidSigningKeyStore>..\myapp.keystore</AndroidSigningKeyStore>
    <AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
    <AndroidSigningKeyPass>SuperSecretPassword!</AndroidSigningKeyPass>
    <AndroidSigningStorePass></AndroidSigningStorePass>
</PropertyGroup>

The characteristic of the app and the users makes it impossible to load the images at runtime, e.g. via https.

colonel666
  • 71
  • 4
  • You need to create assets with aapt2, zip them, and add the zip to the aab modules in MSBuild. I am not sure how to do it in MAUI, but here's how it was done with Xamarin. Two different solutions: 1. [Using Windows and MSBuild](https://github.com/infinitespace-studios/XamarinLegacyDynamicAssetsExample), 2. [Using Windows Subsystem for Linux](https://stackoverflow.com/a/70423660/6129329). – Tommi Gustafsson Oct 10 '22 at 07:25

2 Answers2

1

tl;dr I did not find any Maui answer at this time.
The best starting point looks like XamarinComponent/Android/GoogleAndroidVending.
HOWEVER that wraps a java library, and appears to use gradle, so TBD what knowledge is required to be able to build this, then adapt it for Maui.


The corresponding Xamarin.Forms doc is APK Expansion Files.

The Xamarin.Forms nuget source code and doc is at github XamarinComponents/Android/GoogleAndroidVending.


There is a Nuget link there, but that won't work in .Net Maui.

Until there is a Maui Nuget, it will be necessary to download the source code, and modify it. (If anyone does this, would be good to upload back to github. TBD where.)

App Startup is a bit different in .Net Maui, I did not investigate what might need to change.

In addition, there might be references to Xamarin namespaces that should change to Maui equivalents.

IMPORTANT: This c# code is a wrapper for a java library from Google. The project includes gradle references. TBD what the requirements are to build this.

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
  • I really appreciate your answer. The mentioned github repo GoogleAndroidVending is 5 years old and doesn't even compile. I tried different ways to get it working but with no success – colonel666 Jun 14 '22 at 08:33
  • @colonel666 Did you get it to work with your MAUI project? I'm facing the same issue at the moment... – Soko Jan 24 '23 at 08:34
0

If your APK is getting over 150Mb then I suspect Google and Apple (if you're making an iOS app) will be expecting you to host the image data in the cloud and pull it to the device on an 'as needed' basis so you're not clogging your users' device storage up unnecessarily. That type of static imagery should be stored in cache and not backed up (so you'll need to check if it exists and re-download if necessary).

Red Nightingale
  • 669
  • 3
  • 19