title: Android.app.Application cannot be cast to GoogleAnalyticsApp (libgdx)
body: <p>I am trying to add Google Analytics to my application on Android (LibGDX). But I get ClassCastException </p>
  
  <pre><code>04-06 15:15:07.359: E/AndroidRuntime(7564): java.lang.RuntimeException:
  Unable to start activity
  ComponentInfo{com.mygdx.one4all/com.mygdx.one4all.AndroidLauncher}:
  java.lang.ClassCastException: android.app.Application cannot be cast to 
  com.mygdx.one4all.AnalyticsApp
  </code></pre>
  
  <p>when I try</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) { 
  //...   
     AnalyticsApp an = (AnalyticsApp) getApplication();
  //...
  </code></pre>
  
  <p>My AnalyticsApp:</p>
  
  <pre><code>package com.mygdx.one4all;    
  import com.google.android.gms.analytics.GoogleAnalytics;
  import com.google.android.gms.analytics.Tracker;
  import com.mygdx.one4all.R.xml;    
  import android.app.Application;    
  public class AnalyticsApp extends Application {
      private Tracker mTracker; 
      synchronized public Tracker getDefaultTracker() {
          if (mTracker == null) {
              GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
              mTracker = analytics.newTracker(xml.global_tracker);
          }
          return mTracker;
      }
  }
  </code></pre>
  
  <p>People advise to modify Manifest. But I have my application there.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mygdx.one4all"
      android:versionCode="9"
      android:versionName="1.0" &gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="com.android.vending.BILLING" /&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="9"
          android:targetSdkVersion="23" /&gt;
  
      &lt;application        
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/GdxTheme" &gt;
          &lt;activity
              android:name="com.mygdx.one4all.AndroidLauncher"
              android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
              android:label="@string/app_name"
              android:screenOrientation="portrait" &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="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /&gt;
  
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;        
      &lt;/application&gt;
  
      &lt;application android:name=".AnalyticsApp"
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/GdxTheme"&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>