Compose: painterResource(Int, Composer) not bound in Xamarin.AndroidX.Compose.UI.Android (PainterResources_androidKt wrapper is empty)

Open
#1,443 0 comments 1 reaction 2 assignees View on GitHub

@jonathanpeppers is already working on this.

Since Jun 5, 2026.

  • #1449 by @copilot-swe-agent — closed without merging

Assessment

This issue has not been assessed yet.

Description

Summary

Painter and the painter implementations (BitmapPainter, BrushPainter, ColorPainter) are bound in Xamarin.AndroidX.Compose.UI.Graphics, but the loader painterResource(@DrawableRes id: Int): Painter from androidx.compose.ui.res.PainterResources_androidKt is not reachable from C# — only an empty PainterResources_androidKt wrapper class is emitted, with zero static methods.

Without painterResource, the bound Painter types are unreachable from typical Compose code (Image(painter = painterResource(R.drawable.foo), …)).

Library / NuGet

Verified state today (commit eb2f50b)

source/androidx.compose.ui/ui-android/PublicAPI/PublicAPI.Unshipped.txt contains exactly two PainterResources_androidKt lines:

AndroidX.Compose.UI.Res.PainterResources_androidKt
override AndroidX.Compose.UI.Res.PainterResources_androidKt.JniPeerMembers.get -> Java.Interop.JniPeerMembers!

…i.e. the class wrapper is bound but no painterResource static method is exposed. The Kotlin function is:

@Composable
@ReadOnlyComposable
fun painterResource(@DrawableRes id: Int): Painter

There is no @JvmInline value class parameter, so this is not the same hash-mangled-name pattern as dotnet/java-interop#1440. The @Composable annotation alone causes the JVM signature to include trailing Composer + Int $changed parameters, but those bind fine elsewhere. Something more specific is dropping this overload — likely the @ReadOnlyComposable attribute or the Painter return type's nullability/inheritance metadata.

For comparison, Painter itself binds fine in Xamarin.AndroidX.Compose.UI.Graphics:

AndroidX.Compose.UI.Graphics.Painter.Painter
abstract AndroidX.Compose.UI.Graphics.Painter.Painter.IntrinsicSize.get -> long
virtual AndroidX.Compose.UI.Graphics.Painter.Painter.ApplyAlpha(float alpha) -> bool
virtual AndroidX.Compose.UI.Graphics.Painter.Painter.ApplyColorFilter(AndroidX.Compose.UI.Graphics.ColorFilter? colorFilter) -> bool
…
AndroidX.Compose.UI.Graphics.Painter.BitmapPainter
AndroidX.Compose.UI.Graphics.Painter.BrushPainter
AndroidX.Compose.UI.Graphics.Painter.ColorPainter

Metadata.xml today

source/androidx.compose.ui/ui-android/Transforms/Metadata.xml has surgical removes for inline-class hash-mangled overloads but nothing referencing painterResource / PainterResources_androidKt. The method is being dropped by the binder itself, not by the project's transforms.

Reproduction / evidence

compose-net works around this with a hand-written JNI bridge:

  • ComposeBridges.cs[ComposeBridge(Class = "androidx/compose/ui/res/PainterResources_androidKt", JvmName = "painterResource", Signature = "(ILandroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter;")]

The bridge calls successfully at runtime and returns a usable Painter handle, so the underlying Java method exists and behaves correctly — only the binding-time projection is missing.

Suggested fix

Add the painterResource(int, Composer, int) static to AndroidX.Compose.UI.Res.PainterResources_androidKt. If it can't be generated automatically, an add-node transform in Transforms/Metadata.xml should suffice.

Cross-references

Dominant language
C#
Stars
318
Forks
73
Avg merge
2d 6h
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/android-libraries

All issues in dotnet/android-libraries

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.