Error "Unresolved reference: kotlinx" when importing kotlinx.android.synthetic in Android Studio
Hello everyone! I'm a beginner in Kotlin and Android development. I'm switching from Java and trying to use kotlinx.android.synthetic to simplify working with Views in Activity. I have Android Studio 4.2, project in Kotlin.
I created a simple Activity with TextView:
```kotlin
package com.example.myapp
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.* // <- error here
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
myTextView.text = "Hello from Kotlin!" // myTextView - ID from XML
}
}
```
But the studio underlines the import in red and says: "Unresolved refer
No answers yet.
Log in to leave an answer
Blogs