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

Apache License 2.0
48 stars 75 forks source link

Material Theming: Android Basics with Compose #53

Open SedSim opened 10 months ago

SedSim commented 10 months ago

URL of codelab

https://developer.android.com/codelabs/basic-android-kotlin-compose-material-theming?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-3-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-material-theming#6

In which task and step of the codelab can this issue be found?

"6. For the title parameter, pass in a Row which will hold the Image and Text of the CenterAlignedTopAppBar."

Describe the problem

Code is not compiling and shows error because "CenterAlignedTopAppBar" is experimental and will be removed in future.

Steps to reproduce?

  1. Go through all steps of the codelab and build the app as described without copying the solution code.
  2. Click on... Build & Refresh of the Gradle simulator/ emulator
  3. See error...!

Versions

Android Studio version: Android Studio Flamingo | 2022.2.1 Patch 2 API version of the emulator: API34

Additional information

The solution to the problem is to add "@OptIn(ExperimentalMaterial3Api::class)" before the WoofTopAppBar Composable.

means: ... @OptIn(ExperimentalMaterial3Api::class) @Composable fun WoofTopAppBar(modifier: Modifier = Modifier) { CenterAlignedTopAppBar( ...