LoginSignup
1
1

More than 1 year has passed since last update.

【Jetpack Compose】Image()コンポーザブルが使用できない

Posted at

どういうことか

Androidデベロッパーのチュートリアルをやっている。

画像を表示するためにImageコンポーザブルを追加する、とある。

MainActivity.kt
Image(
   painter = image
)

テキスト通りに進めているハズだがエラーが出て画像を表示できない。

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:

原因と解決

適切な import を行うことで解決する。
チュートリアルには載っていない!

MainActivity.kt
import androidx.compose.foundation.Image

自動補完でやってくれる import が適切なものではないことが多々あるっぽい。
先輩曰く

androidおんなじ名前だけど違う関数間違ってimportするあるあるなので諦めてください

らしい。初心者殺し。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1