Skip to content

Xamarin.AndroidX.Compose.Material.Icons.Core: managed assembly is empty (no Icons type) #1451

@jonathanpeppers

Description

@jonathanpeppers

Background

Xamarin.AndroidX.Compose.Material.Icons.Core (and its .Android
sibling) ships an essentially empty managed assembly. Verified
against 1.7.8.3:

D:\.nuget\packages\xamarin.androidx.compose.material.icons.core\1.7.8.3\
  lib\net10.0-android36.0\Xamarin.AndroidX.Compose.Material.Icons.Core.dll   (16 432 bytes)
var asm = AssemblyDefinition.ReadAssembly(dll);
asm.MainModule.Types.Count        // => 1
asm.MainModule.Types[0].FullName  // => "<Module>"

The underlying AAR contains the androidx.compose.material.icons.Icons
class (with nested Filled / Outlined / Rounded / Sharp /
TwoTone / AutoMirrored companion objects) plus the baseline icon
set (~36 ImageVector extension properties — Icons.Default.Search,
Menu, Add, Delete, Edit, Settings, MoreVert, ArrowBack,
Close, Check, Star, Favorite, Share, Home, Person,
Notifications, Refresh, Info, Warning, …), but none of it
surfaces to managed callers. Today there is no way to write
Icons.Default.Search from C#
without hand-rolling a JNI
GetStaticFieldID lookup per icon.

This blocks any managed Compose effort from using the official
Material icon set — the same baseline icons every Jetpack Compose
sample uses for app-bar navigation, list-item actions, and FAB
contents. (We have an open tracking issue for this on the C# side:
jonathanpeppers/compose-net#61.)

Ask

Mirror the #1438
/ #1439
recipe applied to ui-graphics-android / ui-text-android /
ui-unit-android:

  • Drop the <remove-node path="/api/package" /> (or equivalent
    <remove-node> rules) in
    source/androidx.compose.material.icons/material-icons-core-android/Transforms/Metadata.xml
    (and the JVM-only material-icons-core source if applicable).
  • Add managedName overrides forcing Material.Icons casing on the
    package map:
    • androidx.compose.material.iconsAndroidX.Compose.Material.Icons
    • androidx.compose.material.icons.filledAndroidX.Compose.Material.Icons.Filled
    • androidx.compose.material.icons.outlinedAndroidX.Compose.Material.Icons.Outlined
    • androidx.compose.material.icons.roundedAndroidX.Compose.Material.Icons.Rounded
    • androidx.compose.material.icons.sharpAndroidX.Compose.Material.Icons.Sharp
    • androidx.compose.material.icons.twotoneAndroidX.Compose.Material.Icons.TwoTone
    • androidx.compose.material.icons.automirrored.*
      AndroidX.Compose.Material.Icons.AutoMirrored.*
  • Add Xamarin.AndroidX.Compose.Material.Icons.Core /
    .Android to ComposePackagesWithBindings in
    AndroidXProject.cshtml.
  • Update published-namespaces.txt for the newly-exposed namespaces.
  • Bump nugetVersion on both packages.

After the fix, Icons.Default.Search-style baseline icons should be
callable directly. The 1500+ icon material-icons-extended artifact
has been deprecated upstream by Google, so this issue is intentionally
scoped to material-icons-core only.

Verification

// Should resolve at compile time after the fix:
var v = AndroidX.Compose.Material.Icons.Icons.Filled.Search;
// expected: AndroidX.Compose.UI.Graphics.Vector.ImageVector

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions