google-developer-training / basic-android-kotlin-compose-training-woof

Apache License 2.0
55 stars 83 forks source link

Material Theming: Android Basics with Compose - compile error #94

Closed Nicholas-Ustick closed 6 months ago

Nicholas-Ustick commented 6 months ago

URL of codelab Material Theming with Jetpack Compose

In which task and step of the codelab can this issue be found? 7. Add a top bar

Describe the problem Compile error on CenterAlignedTopAppBar. Error: "This material API is experimental and is likely to change or to be removed in the future."

Steps to reproduce?

  1. Compile the example after placing the CenteralignedTopAppBar in the code.
  2. see Error: "This material API is experimental and is likely to change or to be removed in the future."

Versions Android Studio version: Android Studio Iguana | 2023.2.1 Patch 1 Build #AI-232.10300.40.2321.11567975, built on March 13, 2024 Runtime version: 21+9-b75.2 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11.0 GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 4096M Cores: 16 Registry: ide.experimental.ui=true

Non-Bundled Plugins: com.shuzijun.markdown-editor (2.0.5) com.villains.intelij.plugin.trashpandatheme (2.0.8) Docker (232.10300.41)

API version of the emulator: 34

Additional information Include screenshots if they would be useful in clarifying the problem. Solution to the problem is to add @OptIn(ExperimentalMaterial3Api::class) to the WoofTopAppBar function.

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun WoofTopAppBar(modifier: Modifier = Modifier) {
    CenterAlignedTopAppBar(
        title = {
            Row {
                Image(

Would be helpful if the Codelab guided students to this solution instead of them having to spend a fair bit of time figuring out what to do. OR the CodeLab should be updated to use non-experimental features to avoid potential compiler errors.

Nicholas-Ustick commented 6 months ago

Apologies this appears to be a duplicate of #52.

Nicholas-Ustick commented 6 months ago

37 appears to have the solution, though someone has to add that solution to the starter branch for the code lab.