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

Apache License 2.0
49 stars 71 forks source link

Simple Animation with Jetpack Compose #68

Open Richard5A opened 7 months ago

Richard5A commented 7 months ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-woof-animation?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-woof-animation#1

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

Describe the problem In line 122

...
@Composable
fun WoofTopAppBar(modifier: Modifier = Modifier) { 
    CenterAlignedTopAppBar(
...

is an Error, that you need a @OptIn(ExperimentalMaterial3Api::class)

Steps to reproduce?

  1. Clone https://github.com/google-developer-training/basic-android-kotlin-compose-training-woof.git
  2. Change Branch to material
  3. In MainActivity.kt is the error

Versions Android Studio version: 2023.2.1 API version of the emulator: 33

mirabo-vuongnt1 commented 5 months ago
  1. Edit build.gradle.kts - App level: From implementation("androidx.compose.material3:material3") to: implementation("androidx.compose.material3:material3:1.1.1")

  2. Edit build.gradle.kts - Project level from: id("com.android.application") version "8.0.2" apply false id("com.android.library") version "8.0.2" apply false to: id("com.android.application") version "8.2.0" apply false id("com.android.library") version "8.2.0" apply false

  3. Add anotation: @OptIn(ExperimentalMaterial3Api::class) at Compose function WoofTopAppBar like this: @OptIn(ExperimentalMaterial3Api::class) @Composable fun WoofTopAppBar(modifier: Modifier = Modifier)