Skip to content

Unused MAUI .java not being trimmed #9943

Closed

Description

@RobersonGazolli

Android framework version

net8.0-android

Affected platform version

VS 2022 17.11.2

Description

Image

As shown in the image, the unusable codes are not being removed in the apk compilation.
A project was created in maui for the android platform, but when I generate the apk and decompile the apk in JADX, I see that the WebView codes that were not used at any time are in the apk

Steps to Reproduce

1 Create a new project.
2 Generate the apk file.
3 Open JADX and locate the apk.
4 In the Navigation tab > Search by text
5 In the search box type > Webview

Did you find any workaround?

No response

Relevant log output

Activity

  1. jpobst commented on Mar 19, 2025

    @jpobst
    Contributor

    Are you compiling in Release mode? The trimmer doesn't run in Debug mode.

    You also might want to try .NET 9. I'm not sure that MAUI was fully trimmer enabled in .NET 8.

  2. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    Area: TrimmingIssues with ILLink or NativeAOT related to trimming.
    and removed
    needs-triageIssues that need to be assigned.
    on Mar 19, 2025
  3. changed the title [-]Unusable codes are not being removed[/-] [+]Unused MAUI `.java` not being trimmed[/+] on Mar 19, 2025
  4. added
    need-infoIssues that need more information from the author.
    on Mar 20, 2025
  5. RobersonGazolli commented on Mar 20, 2025

    @RobersonGazolli
    Author

    @jpobst I updated my VS 2022 to .NET 9 latest version, I created a project again and compiled it in Release mode, but I still have the same problem.

  6. added
    need-attentionA xamarin-android contributor needs to review
    and removed
    need-infoIssues that need more information from the author.
    on Mar 20, 2025
  7. dellis1972 commented on Mar 20, 2025

    @dellis1972
    Contributor

    @RobersonGazolli have you disabled the use of r8 by any chance? Its usually r8 which is responsible for removing unused java types from the java side of the app.

  8. 29 remaining items

  9. dellis1972 commented on Mar 24, 2025

    @dellis1972
    Contributor

    Hmm. Its still skipping the _CompileToDalvik target. Did you delete the bin and obj directories?

    Might be better to build from the command line.

    Delete both bin and obj directories then run

    dotnet build C:\Users\Roberson\source\repos\MauiAppNet9\MauiAppNet9.csproj -c Release  -bl
    

    This will output a msbuild.binlog

  10. added
    need-infoIssues that need more information from the author.
    and removed
    need-attentionA xamarin-android contributor needs to review
    on Mar 24, 2025
  11. RobersonGazolli commented on Mar 24, 2025

    @RobersonGazolli
    Author

    Please check now.

    msbuild.zip

  12. added
    need-attentionA xamarin-android contributor needs to review
    and removed
    need-infoIssues that need more information from the author.
    on Mar 24, 2025
  13. RobersonGazolli commented on Mar 25, 2025

    @RobersonGazolli
    Author

    https://github.com/RobersonGazolli/MauiAppNet9.git

    I sent the project to git, so it can be downloaded for better analysis.

  14. RobersonGazolli commented on Sep 25, 2025

    @RobersonGazolli
    Author

    regarding this issue, is there any update?
    @jonpryor @jpobst @dellis1972 @jonathanpeppers

  15. dotnet-policy-service commented on Jul 22, 2026

    @dotnet-policy-service

    We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

  16. dotnet-policy-service commented on Aug 5, 2026

    @dotnet-policy-service

    This issue will now be closed since it had been marked "possibly-stale" but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  17. locked and limited conversation to collaborators on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.Area: TrimmingIssues with ILLink or NativeAOT related to trimming.need-attentionA xamarin-android contributor needs to reviewpossibly-staleIssues that are potentially no longer relevant.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions