Skip to content
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

Missing documentation on recommended release settings. D8andR8.md is likely outdated #8917

Open
hansmbakker opened this issue May 1, 2024 · 3 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. Area: Documentation Issues with documentation.

Comments

@hansmbakker
Copy link

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

Not relevant

Description

This is a documentation issue - I would like to know what optimization settings are recommended when publishing a Release version to the Google Play store.

For Xamarin there was a lot of detailed documentation:

For .NET MAUI there is no equivalent about what settings to use, and in Visual Studio it looks like R8 is the only recommended code shrinker now. I cannot find a ProGuard option in the project settings and the only shrinker option in Visual Studio is R8:
image

However, I cannot find any documentation on the R8 shrinker becoming the new default. In the .NET for Android repo there is https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/D8andR8.md which was last updated 6 years ago.

That document says

If AndroidDexTool is omitted, dx and CompileToDalvik should be used. Until D8/R8 integration is deemed stable and enabled by default.

However, that was 6 years ago...

What are the recommended settings for releasing a .NET for Android / MAUI Android app today?

Steps to Reproduce

Not applicable

Did you find any workaround?

No response

Relevant log output

No response

@hansmbakker hansmbakker added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels May 1, 2024
@hansmbakker hansmbakker changed the title D8/R8 documentation likely outdated Missing documentation on recommended release settings. D8andR8.md is likely outdated May 1, 2024
@jonathanpeppers
Copy link
Member

Google no longer supports DX:

So when you build apps today, it uses D8.

R8 is the equivalent of ProGuard, so that is optional. It would trim unused Java code, but you might have to add some ProGuard rules (same format as before). Not all apps will work with R8 enabled, without adding a few rules.

There might be a section we could add here about this:

@hansmbakker
Copy link
Author

hansmbakker commented May 1, 2024

@jonathanpeppers thank you for the quick answer!

Are there any settings, other than code shrinking, that developers should consider applying when releasing their app?

Regarding the place for documentation - I would expect this to be in the general documentation of .NET for Android / .NET MAUI - not just in the migration documentation (for new developers this is important, too).

I found these pages:

However, from that last page (VS Project Properties) it's not super clear what the implications are between R8 and ProGuard and how to use it:
image

As I understood your answer, R8 might need a similar approach (defining rules) to ProGuard:

R8 is the equivalent of ProGuard, so that is optional. It would trim unused Java code, but you might have to add some ProGuard rules (same format as before). Not all apps will work with R8 enabled, without adding a few rules.

Please note, that for https://learn.microsoft.com/en-us/previous-versions/xamarin/android/deploy-test/release-prep/proguard?tabs=windows there is no replacement in the MAUI documentation either.

Furthermore, it does not feel like a clear and complete overview of suggested settings and things to keep in mind (besides the shrinking).

@jonathanpeppers
Copy link
Member

@hansmbakker the suggestions for Release (and Debug for that matter) are the project template / just leave all the settings blank.

If you have some need beyond that: such as smaller app size (at the cost of extra work r8), or faster startup (at the cost of larger app "AOT everything"). You could consider other settings at that point.

@jpobst jpobst added Area: Documentation Issues with documentation. and removed needs-triage Issues that need to be assigned. labels May 1, 2024
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. Area: Documentation Issues with documentation.
Projects
None yet
Development

No branches or pull requests

4 participants