title: Getting Null pointer exception while running my app
body: <p>Following is the error that I am getting while running my app. My app crashes only when I am trying to open my room activity. Hereby attaching my logcat result and room activity code for your persual...........................................
  .............................................................................................</p>
  <pre><code>    Process: com.example.tictactoe, PID: 5976
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tictactoe/com.example.tictactoe.RoomActivity}: java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3616)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3780)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:233)
          at android.app.ActivityThread.main(ActivityThread.java:8068)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
       Caused by: java.lang.NullPointerException
          at com.example.tictactoe.RoomActivity.onCreate(RoomActivity.kt:22)
          at android.app.Activity.performCreate(Activity.java:8006)
          at android.app.Activity.performCreate(Activity.java:7990)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3589`
  </code></pre>
  <p>Room Activity looks like this</p>
  <pre><code>package com.example.tictactoe
  
  import android.content.Intent
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  import android.widget.Toast
  import com.google.firebase.auth.FirebaseAuth
  import com.google.firebase.database.FirebaseDatabase
  import kotlinx.android.synthetic.main.activity_room.*
  
  
  class RoomActivity : AppCompatActivity() {
  
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_room)
          var mAuth: FirebaseAuth?=null // my authnetication variable
  
          var database = FirebaseDatabase.getInstance()
          var myRef = database.reference
          var currentUser = mAuth!!.currentUser
          mAuth = FirebaseAuth.getInstance()
          buLoginEvent()
      }
  
      fun buLoginEvent(){
         LoginToFirebase(email.text.toString(), password.text.toString());
  
      }
  
      fun LoginToFirebase(email:String, password:String){
          var mAuth: FirebaseAuth?=null // my authnetication variable
  
          var database = FirebaseDatabase.getInstance()
          var myRef = database.reference
          var currentUser = mAuth!!.currentUser
          mAuth!!.createUserWithEmailAndPassword(email,password)
              .addOnCompleteListener(this){
                  task-&gt;
                  if(task.isSuccessful){
                      Toast.makeText(applicationContext,&quot;Successfull Login&quot;, Toast.LENGTH_LONG).show()
                      //saving in database
                      myRef.child(&quot;Users&quot;).child(splitString(currentUser?.email.toString())).setValue(
                          currentUser?.uid
                      )//creating current node iin relatime database
                      LoadMain()
                  }
                  else{
                      Toast.makeText(applicationContext,&quot;Failed Login&quot;, Toast.LENGTH_LONG).show()
                  }
              }
  
      }
  
      override fun onStart() {//2nd time when the application is started then call this method
          super.onStart()
          LoadMain()
      }
      fun  LoadMain(){
          var mAuth: FirebaseAuth?=null // my authnetication variable
  
          var database = FirebaseDatabase.getInstance()
          var myRef = database.reference
          var currentUser = mAuth!!.currentUser
  
          if(currentUser!=null) {// doing this only when the user is not null
  
  
              var intent = Intent(this, OnlineGameActivity::class.java)
              intent.putExtra(&quot;email&quot;, currentUser!!.email)
              intent.putExtra(&quot;uid&quot;, currentUser!!.uid)
  
              startActivity(intent)
              finish()
          }
      }
      fun splitString(str:String):String{
          var split=str.split(&quot;@&quot;)
          return split[0]
      }
  }
  </code></pre>