title: Getting java.lang.ClassCastException Error
body: <p>New to Android development. I haven't started working on my project and its already throwing out errors.
  I've started this thread after going through the rest (none of the solutions worked for me). I'm having trouble finding the ClassCastException. I've only selected the menu as the default template and was trying out Google Admobs</p>
  
  <p>MainActivity.kt</p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
  
      private lateinit var appBarConfiguration: AppBarConfiguration
       lateinit var mAdView : AdView
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          // Google Ad-mobs Code
          setContentView(R.layout.activity_main)
          MobileAds.initialize(this)
          mAdView = findViewById(R.id.adView)
          val adRequest = AdRequest.Builder().build()
          mAdView.loadAd(adRequest)
     // Code for the menu
          val toolbar: Toolbar = findViewById(R.id.toolbar)
          setSupportActionBar(toolbar)
  
          val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
          val navView: NavigationView = findViewById(R.id.nav_view)
          val navController = findNavController(R.id.nav_host_fragment)
          // Passing each menu ID as a set of Ids because each
          // menu should be considered as top level destinations.
          appBarConfiguration = AppBarConfiguration(setOf(
                  R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow), drawerLayout)
          setupActionBarWithNavController(navController, appBarConfiguration)
          navView.setupWithNavController(navController)
      }
  
      override fun onCreateOptionsMenu(menu: Menu): Boolean {
          // Inflate the menu; this adds items to the action bar if it is present.
          menuInflater.inflate(R.menu.main, menu)
          return true
      }
  
      override fun onSupportNavigateUp(): Boolean {
          val navController = findNavController(R.id.nav_host_fragment)
          return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
      }
  
  }
  
  </code></pre>
  
  <p>LogCat</p>
  
  <pre><code>    Process: com.albertjokelin.revise, PID: 10460
      java.lang.RuntimeException: Unable to instantiate application com.albertjokelin.revise.MainActivity: java.lang.ClassCastException: com.albertjokelin.revise.MainActivity cannot be cast to android.app.Application
          at android.app.LoadedApk.makeApplication(LoadedApk.java:1226)
          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
          at android.app.ActivityThread.access$1300(ActivityThread.java:219)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
          at android.os.Handler.dispatchMessage(Handler.java:107)
          at android.os.Looper.loop(Looper.java:214)
          at android.app.ActivityThread.main(ActivityThread.java:7356)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
       Caused by: java.lang.ClassCastException: com.albertjokelin.revise.MainActivity cannot be cast to android.app.Application
          at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
          at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
          at android.app.Instrumentation.newApplication(Instrumentation.java:1148)
          at android.app.LoadedApk.makeApplication(LoadedApk.java:1218)
          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431) 
          at android.app.ActivityThread.access$1300(ActivityThread.java:219) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) 
          at android.os.Handler.dispatchMessage(Handler.java:107) 
          at android.os.Looper.loop(Looper.java:214) 
          at android.app.ActivityThread.main(ActivityThread.java:7356) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
  2020-04-18 11:12:28.865 10460-10460/com.albertjokelin.revise I/Process: Sending signal. PID: 10460 SIG: 9
  </code></pre>
  
  <p>One of the answers told that I've been converting an object of one class to another. But I don't see where I'm making the error. (Sorry just a noob)</p>