title: java.lang.ClassCastException: ish.message.Message cannot be cast to android.app.Application
body: <p>I'm making an app, which is throwing the "ClassCastException: cannot be cast to android.app.Application".
  I've referred various similar questions on stackoverflow but none of the answers solve my problem.</p>
  
  <p>Here's my code: </p>
  
  <p>MainActivity.java:</p>
  
  <pre><code>public class MainActivity extends ListActivity {
  
  private List&lt;Note&gt; posts;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
      setContentView(R.layout.activity_main);
  
  
      //gets current user
      ParseUser currentUser = ParseUser.getCurrentUser();
  
      //checks if a user has already logged in
      if (currentUser == null) {
  
          //loads the sign in/sign up page
          loadLoginView();
      }
  
  
      //now after a user has logged in...
  
      //creates an array adapter to hold the posts
      posts = new ArrayList&lt;Note&gt;();
      ArrayAdapter&lt;Note&gt; adapter = new ArrayAdapter&lt;Note&gt;(this,
              R.layout.list_item_layout, posts);
      setListAdapter(adapter);
  
      //Refreshes posts
      refreshPostList();
  }
  
  
  
  private void loadLoginView() {
      Intent intent = new Intent(this, LoginActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
      startActivity(intent);
  }
  
  
  
  
  
  
  
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
  
      Note note = posts.get(position);
      Intent intent = new Intent(this, EditNoteActivity.class);
      intent.putExtra("noteId", note.getId());
      intent.putExtra("noteTitle", note.getTitle());
      intent.putExtra("noteContent", note.getContent());
      startActivity(intent);
  
  }
  
  private void refreshPostList() {
  
      //query gets access to posts in parse
      ParseQuery&lt;ParseObject&gt; query = ParseQuery.getQuery("Post");
      query.whereEqualTo("author", ParseUser.getCurrentUser());
  
  
      setProgressBarIndeterminateVisibility(true);
  
      query.findInBackground(new FindCallback&lt;ParseObject&gt;() {
  
          @SuppressWarnings("unchecked")
          @Override
          public void done(List&lt;ParseObject&gt; postList, ParseException e) {
              setProgressBarIndeterminateVisibility(false);
              if (e == null) {
                  // If there are results, update the list of posts
                  // and notify the adapter
                  posts.clear();
                  for (ParseObject post : postList) {
                      Note note = new Note(post.getObjectId(), post
                              .getString("title"), post.getString("content"));
                      posts.add(note);
                  }
                  ((ArrayAdapter&lt;Note&gt;) getListAdapter())
                          .notifyDataSetChanged();
              } else {
  
                  Log.d(getClass().getSimpleName(), "Error: " + e.getMessage());
              }
  
          }
  
      });
  
  }
  }
  </code></pre>
  
  <p>Android Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="ish.message"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="11"
      android:targetSdkVersion="21" /&gt;
  
   &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  
  &lt;application
      android:name=".Message"
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name" &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;activity
          android:name=".EditNoteActivity"
          android:label="@string/title_activity_edit_note" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="ish.message.MainActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".LoginActivity"
          android:label="@string/title_activity_login" &gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".SignUpActivity"
          android:label="@string/title_activity_sign_up" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="ish.message.LoginActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".Users"
          android:label="@string/title_activity_users" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="ish.message.MainActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".Message"
          android:label="@string/title_activity_message" &gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".EditTextMessage"
          android:label="@string/title_activity_edit_text_message" &gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Logcat trace:</p>
  
  <pre><code>09-18 21:24:44.507: E/AndroidRuntime(19919): FATAL EXCEPTION: main
  09-18 21:24:44.507: E/AndroidRuntime(19919): java.lang.RuntimeException: Unable to instantiate application ish.message.Message: java.lang.ClassCastException: ish.message.Message cannot be cast to android.app.Application
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4263)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.ActivityThread.access$1400(ActivityThread.java:143)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.os.Handler.dispatchMessage(Handler.java:99)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.os.Looper.loop(Looper.java:137)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.ActivityThread.main(ActivityThread.java:4960)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at java.lang.reflect.Method.invokeNative(Native Method)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at java.lang.reflect.Method.invoke(Method.java:511)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at dalvik.system.NativeStart.main(Native Method)
  09-18 21:24:44.507: E/AndroidRuntime(19919): Caused by: java.lang.ClassCastException: ish.message.Message cannot be cast to android.app.Application
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.Instrumentation.newApplication(Instrumentation.java:997)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.Instrumentation.newApplication(Instrumentation.java:982)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
  09-18 21:24:44.507: E/AndroidRuntime(19919):    ... 11 more
  </code></pre>
  
  <p>Feel free to ask for more details if needed.</p>