'Why can't I display my data from firebase?

I have a problem because I can’t display my data from firestore. I want to take my id from the xml. I’ve written this with help from a video and when they write the id it gets it immediately, but mine doesn’t.
This is the video

Main activity.kt

private fun retrivePerson() = CoroutineScope(Dispatchers.IO).launch {
    try {
        val querySnapshot = personCollectionName.get().await()
        val sb = StringBuilder()
        for (document in querySnapshot.documents) {
            val users = document.toObject<users>()
            sb.append("$users\n")
        }
        withContext(Dispatchers.Main) {
            uzytkownik.text = sb.toString()
           /* val imie = findViewById<TextView>(R.id.uzytkownik).apply {

                text = "Witaj, " + sb.toString()*/
            }
        }
    } catch (e: Exception) {
        withContext(Dispatchers.Main) {
            Toast.makeText(this@MainActivity, e.message, Toast.LENGTH_LONG).show()
        }
    }

main xml

 <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="245dp"
        android:layout_height="66dp"
        android:layout_marginTop="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/uzytkownik"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Witaj,"
            android:textColor="@android:color/black"
            android:textSize="18sp" />

    </ScrollView>

error id user
error id user



Solution 1:[1]

In the video, he's using KotlinX.synthetics, which is a way to access XML view components in your code. This is actually deprecated at this point as you should use View Binding instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MFazio23