Skip to content

.NET 11 RC2 MAUI app fails to compile (NativeAOT) with MAUI Community Toolkit #13143

Closed

Description

@daltzctr

Android framework version

net11.0-android (Preview)

Affected platform version

.NET 11 RC2

Description

The following exception occurs at build time (after clean bin/obj folders) when trying to publish an Android application with NativeAOT turned on. macOS/iOS build and run NativeAOT fine.

obj\Release\net11.0-android\typemap\java\scrc64243bbae2d1378c01\BoundServiceBinder.java:24: error: package scrc64d4e0e3a6d812f4d7 does not exist
    public BoundServiceBinder (scrc64d4e0e3a6d812f4d7.MediaControlsService p0)
                                                     ^
obj\Release\net11.0-android\typemap\java\scrc64243bbae2d1378c01\BoundServiceBinder.java:32: error: package scrc64d4e0e3a6d812f4d7 does not exist
    private native void nctor_2 (scrc64d4e0e3a6d812f4d7.MediaControlsService p0);
                                                       ^
2 errors
3 warnings

Steps to Reproduce

N/A - haven't tried to reproduce it

Did you find any workaround?

No

Relevant log output

Activity

  1. added
    Area: App+Library Build
    needs-triage
    on Oct 14, 2026
  2. changed the title [-].NET 11 RC2 MAUI app fails to compile with MAUI Community Toolkit[/-] [+].NET 11 RC2 MAUI app fails to compile (NativeAOT) with MAUI Community Toolkit[/+] on Oct 14, 2026
  3. simonrozsival commented on Oct 14, 2026

    @simonrozsival
    Member

    Reproduced locally with a minimal .NET 11 Android NativeAOT app, without MAUI or CommunityToolkit dependencies.

    The root cause is inconsistent Java-name resolution in the trimmable typemap scanner. MediaControlsService declares [Service(Name = "communityToolkit.maui.media.services")], and its Java wrapper is generated with that explicit name. However, when resolving the service type for BoundServiceBinder’s constructor signature, JavaPeerScanner.GetJniObjectDescriptor checks [Register] and then falls back to an autogenerated CRC64 name, ignoring the component attribute’s explicit Name.

    Consequently, both the generated Java constructor and its nctor_2 native declaration reference a class that was never generated, producing the two reported javac errors. This is a naming mismatch, not the service being removed by trimming or a missing Java dependency. The same gap exists in current main.

    The fix is to consult the indexed component attribute’s JNI name after [Register] and before the CRC64 fallback, matching wrapper generation’s precedence. I am implementing that correction with regression coverage for named components in constructor and exported object/array signatures. An isolated corrected scanner generates wrappers that compile with javac; full rebuilt-SDK validation is still in progress.

    As a workaround, publishing the minimal app with PublishAot=false succeeds. Adding [Register] matching the service’s configured Java name also allows its NativeAOT publish to succeed, but applying that workaround to the Toolkit service would require changing/rebuilding Toolkit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library Buildneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions