Android Asset Delivery in Dotnet Maui

Viewed 364

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.

1 Answers

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.

Related