Ketoy

← SDK updates

Alpha

Drawables: Image(painterResource(R.drawable.X), …)

May 19, 2026 · SDK · 0.3.4-alpha

Same shape, same R8-safe pattern, applied to drawables.

In your KBC source

ProductCard.kt
@KetoyComposable
fun ProductCard() {
  Image(
      painter = painterResource(R.drawable.hero),
      contentDescription = "Hero image",
      modifier = Modifier
          .fillMaxWidth()
          .height(180.dp)
          .clip(RoundedCornerShape(16.dp)),
      contentScale = ContentScale.Crop,
  )
}

Vector drawables, PNGs, WebPs, anything painterResource already handles in your existing Compose code. The compiler plugin collapses painterResource(R.drawable.X) into a string literal carrying just the resource name; the new IMAGE adapter (ID 0x0024) calls getPainter(...) at render time and the host resolver hands back the right Painter.

Wiring it on the host, with Hilt

KetoyModule.kt
@Provides
@Singleton
fun provideMaterialDrawableResolver(): MaterialDrawableResolver =
  materialDrawableResolver {
      register("hero", R.drawable.hero)
      register("logo", R.drawable.logo)
  }

@Provides
@Singleton
fun provideKetoyConfigCustomizer(
  drawableResolver: MaterialDrawableResolver,
): KetoyConfigCustomizer = KetoyConfigCustomizer { default ->
  default.copy(drawableResolver = drawableResolver)
}

Wiring it on the host, without Hilt

MyApplication.kt
override fun onCreate() {
  super.onCreate()

  val drawableResolver = materialDrawableResolver {
      register("hero", R.drawable.hero)
      register("logo", R.drawable.logo)
  }

  val config = KetoyConfig(drawableResolver = drawableResolver)

  ketoyRuntime = KetoyRuntime(
      capabilityRegistry = CapabilityRegistry().apply {
          registerCoreCapabilities(context = this@MyApplication)
      },
      config = config,
  )
}

The R.drawable.X reference is a compile-time field read, R8 keeps the drawable alive in release builds automatically.

Combine with fonts, icons, and the rest

Resolvers compose cleanly. A real production setup typically wires all three resource resolvers together:

KetoyConfig.kt
default.copy(
  imageVectorResolver = materialIconsResolver,    // Material icons
  fontFamilyResolver  = fontFamilyResolver,       // R.font.X
  drawableResolver    = drawableResolver,         // R.drawable.X
)

Each one is independent, register only what your KBC source uses.

painterResource()VectorDrawablePNG · WebPR8-safe