exception android.support.multidex.MultiDexApplication cannot be cast class

I think you should extend the AnalyticsApplication class into your own class, like this:

public class YourApplicationName extends AnalyticsApplication {

     @Override
     protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          setContentView(R.layout.activity_splash);

          //Analitycs
          AnalyticsApplication application = (AnalyticsApplication) getApplication();
          mTracker = application.getDefaultTracker();
          mTracker.setScreenName("Splash");
          mTracker.send(new HitBuilders.ScreenViewBuilder().build());
     }

     // Here you will enable Multidex
     @Override
     protected void attachBaseContext(Context base) {
          super.attachBaseContext(base);
          MultiDex.install(getBaseContext());
     }

}

After this, you must change your AndroidManifest.xml file to this:

<application
     android:name="path.to.YourApplicationName"
     ...

Please, check this link for more information: http://developer.android.com/reference/android/support/multidex/MultiDex.html


I have the same issue this cause of you set android:name="android.support.multidex.MultiDexApplication" in your manifest so your application call is type of MultiDexApplication

<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activityandroid:name=".Splash">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN"/>
<categoryandroid:name="android.intent.category.LAUNCHER"/>
</intent-filter></activity>
</application>

my application class

public class MyApplication extends Application {


    public enum TrackerName {
        APP_TRACKER, // tracker used only in this app
        GLOBAL_TRACKER, // tracker used by all the apps from a company . eg: roll-up tracking.
        ECOMMERCE_TRACKER, // tracker used by all ecommerce transactions from a company .
    }

    public HashMap<TrackerName, Tracker> mTrackers = new HashMap<>();

    public synchronized Tracker getTracker(TrackerName trackerId) {
        if (!mTrackers.containsKey(trackerId)) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            Tracker tracker = (trackerId == TrackerName.APP_TRACKER)?analytics.newTracker(Property_ID)
                    : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker)
                    : analytics.newTracker(R.xml.ecommerce_tracker);
            mTrackers.put(trackerId , tracker);
        }
        return  mTrackers.get(trackerId);
    }


    private Activity mCurrentActivity = null;

    public void setCurrentActivity(Activity mCurrectActivity) {
        this.mCurrentActivity = mCurrectActivity;
    }

    public Activity getCurrentActivity() {
        return mCurrentActivity;
    }

    private static Context mAppContext;

    private static MyApplication mInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        MultiDex.install(this);
        mInstance = this;
        this.setAppContext(getApplicationContext());
    }

    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    public static MyApplication getInstance() {
        return mInstance;
    }

    public static Context getAppContext() {
        return mAppContext;
    }

    public void setAppContext(Context mAppContext) {
        this.mAppContext = mAppContext;
    }

}

this why when I call this method (initialize application instance ) it crash , it try cast MultiDexApplication to MyApplication

MyApplication application = (MyApplication)getApplication();

so to fix this issue just change your manifest attribute name to MyApplication

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name=".MyApplication"> // add path to your application class here 

You should extend your Application class from MultidexApplication and use it in manifest instead of using android.support.multidex.MultiDexApplication directly.