Avatar ·

App crashes with error "Unfortunately MyApp has stopped" — how to fix?

Hello everyone! I'm a beginner in Android development with Kotlin, and I've encountered a problem. My app crashes with the message "Unfortunately MyApp has stopped" immediately after launch or when navigating to a specific screen. I can't figure out what's wrong because no detailed error message is shown in the UI. Here is my code in MainActivity.kt: ```kotlin class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val user = intent.getSerializableExtra("user") as User val name = user.name Toast.makeText(this, "Привет, $name", Toast.LENGTH_LONG).show() } } data class User(val name: String, val age: Int) ``` I am passing a User object from another activity via Intent, but the app crashes. In the Logcat logs, I see something about NullPointerException, but I don't understand where exactly the error is. Please advise how to do it correctly.