Android Asset Delivery in Dotnet Maui

A7md 6 Reputation points
2022-05-31T14:10:16.777+00:00

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.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,419 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 74,641 Reputation points Microsoft Vendor
    2022-06-01T08:12:15.683+00:00

    Hello,​

    Is it possible to add some elements to the csproj-file to do this,

    No, <AndroidDynamicFeature> is not supported.

    But you can run a custom target by aapt2 that could build the feature and add distribution delivery elements in AndoridManfiest.xml . For more details, please check this github issue. https://github.com/xamarin/xamarin-android/issues/4810#issuecomment-737229807

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.