0

I am building an Android app and am using Material3 Theme Builder. I am able to export my custom theme as a zip with Theme.kt. I add it to my folder and made sure to update my package name because Theme.kt defaults to com.example.ui.Theme . I am running into some import issues with material3. Here is the imports in my header.

import androidx.compose.material.MaterialTheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.material3.darkColorScheme

I also tried to add the latest version of com.google.android.material.material 1.8.0-alpha01

into my gradle file but it breaks some other imports in some of my other files like

import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes

Before I changed anything in my gradle file my implementation line looked like this. implementation "androidx.compose.material:material:$compose_version" I am compiling on SDK 32 and the newest version of Gradle and Android Studio Dolphin. Any suggestions on what I could do to properly import material3?

2 Answers2

2

To use Compose M3 you should add this dependency in your build.gradle:

implementation "androidx.compose.material3:material3:$material3_version"

Currently the latest version is 1.0.0-beta03.

Then you have to import the classes in the material3 package, for example:

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme

Finally:

com.google.android.material.material 1.8.0-alpha01

This dependency is the Material Components for Android and it is not related to Compose.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

This is what ended up working for me.

dependencies {
    implementation 'com.google.android.material:material:1.8.0-alpha01'
    implementation "androidx.compose.material3:material3:1.0.0-beta03"

I added these to my build.gradle file.