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

First Android app: Android Basics with Compose

Opened this issue · 0 comments

URL of codelab

In which task and step of the codelab can this issue be found?
STEP 4: Update the text

Describe the problem
The code auto generated is not the same as the one in the code example. The one made by andriod studio is

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            GreetingCardTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Greeting(
                        name = "Android",
                        modifier = Modifier.padding(innerPadding)
                    )
                }
            }
        }
    }
}

While the one in the example is this

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            GreetingCardTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Greeting("Android")
                }
            }
        }
    }
}

Pasting the code in the site into the app produces the following result
image

Steps to reproduce?

  1. File > New > New Project
  2. Select empty activity
  3. Create the app

Versions
Android Studio version: Android Studio Koala | 2024.1.1 Patch 2 AI-241.18034.62.2411.12169540 August 1, 2024