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

Apache License 2.0
125 stars 95 forks source link

First Android app: Android Basics with Compose #874

Open JK-B0T opened 1 month ago

JK-B0T commented 1 month 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? Task 5 step 3.

Describe the problem Surface() won't work if written manually, You have to click on the "Surface" suggestion instead while writing the word and then replace the curly braces with parenthesis.

Steps to reproduce?

  1. Go to line 38.
  2. Select "text" and press alt+enter.
  3. Click on "Surround with widget".
  4. Select "Box" and write "Surface()"
  5. Compilation error "Unresolved reference: Surface" and "@Composable invocations can only happen from the context of a @Composable function" should appear

Versions Android Studio version: Android Studio Ladybug | 2024.2.1 API version of the emulator: n/a

Additional information Screenshot 2024-10-12 205644 Screenshot 2024-10-12 205607 Include screenshots if they would be useful in clarifying the problem.

JK-B0T commented 1 month ago

I just notice, the import "import androidx.compose.material3.Surface" was not there, the suggestion must have add it, and I was deleting it by doing ctrl+z to replicate the error, I may have optimized the imports before adding the surface, if that is the case then maybe the imports you need for it to work should be clarified instead of giving a piece of code and saying "It should look similar to this" or "i'll now look like this" (In fact, copping and pasting the code of the imports that should be there just gets me more errors, not taking into account the package theme import).