google-developer-training / basic-android-kotlin-compose-birthday-card-app

Apache License 2.0
121 stars 95 forks source link

First Android app: Android Basics with Compose #811

Open daniel-tickell opened 2 months ago

daniel-tickell commented 2 months ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-first-app?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-1-pathway-2%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-first-app#4

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

Describe the problem After adding the code in section 9 of this step I get an error on the Text() block that says "@Composable invocations can only happen in the context of a @Composable function"

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions Android Studio version: AI-241.18034.62.2411.12071903 API version of the emulator:

Additional information Include screenshots if they would be useful in clarifying the problem.

daniel-tickell commented 2 months ago

Found that the import androidx.compose.material3.Surface

Was missing from the tutorial, as the standard imports dont include this, and there is no step to add.

Suggest an update to step 6 to include the surface import statement as well