Skip to content

[NativeAOT] [MetaData] on Application class missing from manifest #13175

Open

Description

@tipa

Android framework version

net11.0-android (Preview)

Affected platform version

.NET SDK 11.0.100-rc.2.26504.105

Description

While testing NativeAOT, I noticed that [MetaData] attributes on my Application class aren't included in the generated AndroidManifest.xml. The same attributes work with the default CoreCLR configuration.

This caused Google Maps to crash with “API key not found”, even though the key is declared on the Application class.

I've attached a small repro without any Google Maps dependency. Both Value and Resource metadata are affected. Metadata on an Activity, at assembly scope, or written directly in AndroidManifest.xml works.

I also tried CoreCLR with AndroidTypeMapImplementation=trimmable, which has the same problem.

It looks like UpdateApplicationElement copies the application properties but doesn't write component.MetaData:

internal static void UpdateApplicationElement (XElement app, JavaPeerInfo peer, int targetSdkVersion = 0)
{
string jniName = JniSignatureHelper.JniNameToJavaBinaryName (peer.JavaName);
app.SetAttributeValue (AttName, jniName);
var component = peer.ComponentAttribute;
if (component is null) {
return;
}
PropertyMapper.ApplyMappings (app, component.Properties, PropertyMapper.ApplicationElementMappings, targetSdkVersion: targetSdkVersion);
}

Steps to Reproduce

  1. Extract the ManifestMetadataRepro.zip into two separate folders.
  2. In the first folder, run:
    dotnet publish -c Release -r android-arm64 -p:PublishAot=false
  3. In the second folder, run:
    dotnet publish -c Release -r android-arm64 -p:PublishAot=true
  4. Compare obj/Release/net11.0-android/android-arm64/android/AndroidManifest.xml from both folders.

The CoreCLR manifest contains repro.application.value and repro.application.resource. Both are missing from the NativeAOT manifest, although both builds succeed.

Did you find any workaround?

Moving the attributes to assembly scope works:

[assembly: MetaData("repro.application.value", Value = "application-present")]
[assembly: MetaData("repro.application.resource", Resource = "@string/repro_value")]

Declaring the entries directly in AndroidManifest.xml also works.

Activity

  1. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    needs-triageIssues that need to be assigned.
    on Oct 18, 2026
  2. added
    bugComponent does not function as intended.
    and removed
    needs-triageIssues that need to be assigned.
    on Oct 20, 2026
  3. added this to the .NET 11 milestone on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.bugComponent does not function as intended.trimmable-type-map

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions