Trying to import android compose icons using import androidx.compose.material.icons.filled.Home


I am trying to do an example from a book using android compose but are having problems with the import of the icon image .

According to the example I should use "import androidx..compose.material.icons.filled.Home" but Android Studio gives error on the "icons" part. I understand that there has been some changes on how icons are handled but according to documentation using the icon library should still work even if it is not recommended. I am using Android studio Quail 1 as IDE

0
Oct 11 at 10:09 PM
User AvatarUlf Edholm
#android#kotlin#icons

Accepted Answer

The icons aren't part of Material 3. They are in a separate library, material-icons-core.Add it to your app's build.gradle.kts

dependencies {
    implementation("androidx.compose.material:material-icons-core:1.7.8")
}

Sync Gradle and the import works
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
If the book uses icons that aren't in the core set, use material-icons-extended instead

User AvatarEmmanuel Obiechina Ikenna
Oct 11 at 10:39 PM
1