title: app crashes as the late init property has not been initialized in android studio
body: <p>I have a button, when i click on that, it should show the Alert dialog box, But app crashes when i click on that button I know the code flow is this but I dont know Where i had done my mistake</p>
  <pre><code>      private lateinit var btn: Button
        
   override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_dynam)
          btn = findViewById(R.id.add1)
          buildDialog()
  
          btn.setOnClickListener(object : View.OnClickListener {
              override fun onClick(v: View?) {
                dialog.show()
              }
          })
      }
  
      private fun buildDialog() {
          val builder=android.app.AlertDialog.Builder(this)
          val view=layoutInflater.inflate(R.layout.dialog_dynam,null)
        val name=  view.findViewById&lt;EditText&gt;(R.id.nameEdit)
          builder.setView(view)
          builder.setTitle(&quot;Enter name&quot;)
              .setPositiveButton(&quot;Ok&quot;,object :DialogInterface.OnClickListener{
                  override fun onClick(dialog: DialogInterface?, p1: Int) {
  addname(name.text.toString())
  
                  }`
  </code></pre>