Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Document Default RDIs From .net 8 #10064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
divil5000 opened this issue Apr 22, 2025 · 8 comments
Open

Document Default RDIs From .net 8 #10064

divil5000 opened this issue Apr 22, 2025 · 8 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. need-attention A xamarin-android contributor needs to review

Comments

@divil5000
Copy link

Android framework version

net9.0-android

Affected platform version

VS 2022, Command Line Builds

Description

There exists a pull request, below, where you have removed runtime identifiers from builds by default in .net 9, which means unsuspecting companies upgrading from .net 8 to .net 9 will suddenly find that they have lots of unhappy customers for whom their app no longer installs.

#9179

Unfortunately, I have been unable to find a list of runtime identifiers that were built for by default on .net 8. If I turn on all four RDIs in that link, our .apk file jumps to over 73mb, whereas builds in .net 8 have always been approximately 43mb.

Either I am missing which RDIs should be set to replicate the output from .net 8, in which case they need to be documented somewhere, OR .net 9 has massively increased the size of our published output, in which case it would be good to understand why.

Steps to Reproduce

Start with an existing non-trivial android application in .net 8, and ensure no element is present in the project file. Observe its packaged size when built. Change the target framework to .net 9 and build again, and you'll see initially that the packaged size has decreased, but then turn on all four runtime identifiers from the link above, and you'll see it has increased substantially.

Did you find any workaround?

No response

Relevant log output

@divil5000 divil5000 added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Apr 22, 2025
@jonathanpeppers
Copy link
Member

I have been unable to find a list of runtime identifiers that were built for by default on .net 8. If I turn on all four RDIs

It sounds like you already found them, they are:

<RuntimeIdentifiers>android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>

our .apk file jumps to over 73mb, whereas builds in .net 8 have always been approximately 43mb.

So, a difference between .NET 8 and 9, is we more strictly split up .NET assemblies per-architecture with app bundles. Previously, in .NET 8 you would end up with 4 copies of System.Private.CoreLib.dll for every arch, even though 1 would be loaded at runtime. Now all assemblies are split up, and Google Play only gives the set of .NET assemblies that run on that architecture.

Are you deploying on Google Play, or something else? You may be better off using Google Play's app size estimates as those will be more accurate than comparing the size of an .apk file.

@jonathanpeppers jonathanpeppers added need-info Issues that need more information from the author. and removed needs-triage Issues that need to be assigned. labels Apr 22, 2025
@divil5000
Copy link
Author

Thanks Jonathan. It wasn't clear that .net 8 built for all those RDIs, only that those were all the possible RDIs.

We build one APK, and that is made available on Google Play and also on our own website.

@dotnet-policy-service dotnet-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Apr 22, 2025
@dellis1972
Copy link
Contributor

not sure if google play will optimize an .apk... It might be better to use the .aab format for google play.
That won't help for a direct download though, you'll still need to use .apk for that.

@divil5000
Copy link
Author

We never migrated to .aab. Perhaps now is the time.

However, since we are not using an app bundle, I an unclear as to whether @jonathanpeppers theory would hold in this case.

@jonathanpeppers
Copy link
Member

If you have a single .apk for all architectures, it makes sense that it would grow between .NET 8 and 9.

So, I think your path forward is:

  1. Use app bundles, Google Play already supports them. Requires them for new apps.
  2. For your website, you can run bundletool to split the app bundle into 4 .apk files

The benefit for no. 2, is the download will be smaller, but either the user (or your website) will need to select the correct .apk.

The way this works, bundletool build-apks command creates an "apk set":

build-apks command:
    Generates an APK Set archive containing either all possible split APKs and
    standalone APKs or APKs optimized for the connected device (see connected-
    device flag).

Which is in .\obj\Release\net10.0-android\android\bin\com.companyname.helloandroid-Universal.apks if you want an example of one.

Then bundletool can create an .apk for each architecture with bundletool extract-apks using "supportedAbis": ["arm64-v8a", "armeabi-v7a"] mentioned here:

extract-apks command:
    Extracts from an APK Set the APKs that should be installed on a given
    device.

More info on this here:

@divil5000
Copy link
Author

Thanks Jonathan. The website distribution is sufficiently niche that I don't mind the files being larger, and it certainly isn't worth my splitting them up to create separate downloads.

Presumably then, the nearly 70% growth in the .apk is just general bloat in all the .net libraries? There doesn't seem to be anything else left to explain it.

Sounds like I need to read up on migrating to producing app bundles.

@jonathanpeppers
Copy link
Member

.NET 9 has a copy of all .dll files per architecture.

.NET 8 shared most of the .dll files, except System.Private.CoreLib.dll.

@divil5000
Copy link
Author

Ah, I see. Thanks, that must explain it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects. need-attention A xamarin-android contributor needs to review
Projects
None yet
Development

No branches or pull requests

3 participants