
KMPプロジェクトでMaterial3を使いたい

geDem
KMPでMaterial3が使えない!?
WizardでKMPプロジェクトを作成しました。
KMPでMaterialThemeを使おうと思いましたが、補完機能に出てきたのがMaterial3ではなくMaterialのものでした。
解決方法
gradleを変えるだけで解決しました。↓
build.gradle.ktssourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material) // ←「material」を「material3」に変えるだけ
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.lifecycle.runtime.compose)
}
}
🙂↕️最後まで読んでいただきありがとうございます🙂↕️