title: android.app.Application cannot be cast despite being mentioned in the Manifest
body: <p>I have looked at all the solutions in StackOverflow, but all of them are telling to add <code>android:name</code> in the application tag, which I have already done</p>
  
  <p>I'm trying to experiment with Kotlin in Android app development. Here is my <code>MainActivity</code></p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
  
      val REQ_CODE_SPEECH_INPUT = 100
      var output: TextView? = null
      lateinit var app : SpeechApp
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          output = findViewById(R.id.output)
  
          app = application as SpeechApp
      }
  
      override fun onCreateOptionsMenu(menu: Menu?): Boolean {
          menuInflater.inflate(R.menu.menu_speech, menu)
          return true
      }
  }
  </code></pre>
  
  <p>In <code>onCreate()</code> last line, <code>application</code> refers to <code>getApplication()</code> method of <code>Activity</code> class. Here is my <code>SpeechApp</code>:</p>
  
  <pre><code>class SpeechApp: Application() {
      var isDictionaryRead = false
      lateinit var wordslist : ArrayList&lt;String&gt;
  
      override fun onCreate() {
          super.onCreate()
  
          Thread() {
              Runnable {
                  /* Some Code here */
              }
          }.start()
      }
  }
  </code></pre>
  
  <p>Now here is my Manifest. Do note the <code>android:name</code> specified there.</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="me.sparker0i.speechcorrection"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:name=".app.SpeechApp"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".activity.MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Despite having done all of that, I get this error:</p>
  
  <pre><code>07-01 01:40:27.983 11892-11892/? E/AndroidRuntime: FATAL EXCEPTION: main
  Process: me.sparker0i.speechcorrection, PID: 11892
  java.lang.RuntimeException: Unable to start activity ComponentInfo{me.sparker0i.speechcorrection/me.sparker0i.speechcorrection.activity.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to me.sparker0i.speechcorrection.app.SpeechApp
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
      at android.app.ActivityThread.-wrap11(Unknown Source:0)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6501)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
   Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to me.sparker0i.speechcorrection.app.SpeechApp
      at me.sparker0i.speechcorrection.activity.MainActivity.onCreate(MainActivity.kt:34)
      at android.app.Activity.performCreate(Activity.java:7036)
      at android.app.Activity.performCreate(Activity.java:7027)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
      at android.app.ActivityThread.-wrap11(Unknown Source:0) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:164) 
      at android.app.ActivityThread.main(ActivityThread.java:6501) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
  </code></pre>
  
  <p>PS. Line 34 in MainActivity points to the line in <code>onCreate()</code> where I am giving the value to <code>app</code></p>