@Override
 protected void attachBaseContext(Context base) {
   super.attachBaseContext(base);
   try {
     MultiDex.install(this);
   } catch (NoClassDefFoundError error) {
     LoggingUtil.e(
         "Multi-Dex dependency not included! Please add 'compile 'com.android.support:multidex:1.0.1'' to your Gradle File if you want to use Multi-Dexing");
   }
 }
  private synchronized Tracker getDefaultTracker() {

    try {
      if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        mTracker = analytics.newTracker(SpilConfig.getInstance(this).getGoogleAnalyticsId());
        mTracker.enableExceptionReporting(true);
        mTracker.enableAutoActivityTracking(true);

        return mTracker;
      }
    } catch (Exception | NoClassDefFoundError e) {
      LoggingUtil.v(
          "Google Analytics couldn't be initialised. "
              + "Please make sure you have the necessary dependencies and you included the 'googleAnalyticsId' key-value in your 'defaultGameConfig.json' file");
    }

    return null;
  }
  @Override
  public void onCreate() {
    LoggingUtil.v("Called SpilSDKApplication.onCreate()");

    try {
      Class.forName("android.os.AsyncTask");
    } catch (Throwable ignore) {
      // ignored
    }

    // Crash Reporting
    ACRA.init(this);
    CrashReportUtil crashReportUtil = new CrashReportUtil();
    ACRA.getErrorReporter().setReportSender(crashReportUtil);

    super.onCreate();

    // Google Analytics
    getDefaultTracker();

    // Adjust
    try {
      String appToken = SpilConfig.getInstance(this).getAdjustAppToken();
      String environment;
      if (SpilConfig.getInstance(this).isDebugModeEnabled()) {
        environment = AdjustConfig.ENVIRONMENT_SANDBOX;
      } else {
        environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
      }

      if (appToken != null) {
        if (!appToken.isEmpty() || appToken.length() > 0) {
          LoggingUtil.d("Enabling Adjust");
          AdjustConfig adjustConfig = new AdjustConfig(this, appToken, environment);
          Adjust.onCreate(adjustConfig);

          registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
        }
      }
    } catch (NoClassDefFoundError error) {
      LoggingUtil.e(
          "Spil Adjust Module not included! If you want to use Adjust please include the spilsdk-adjust dependency");
    }

    try {
      String subdomain = SpilConfig.getInstance(this).getZendeskSubdomain();
      String appId = SpilConfig.getInstance(this).getZendeskAppId();
      String oauthClientId = SpilConfig.getInstance(this).getZendeskOauthClientId();

      if (subdomain.length() > 0
          && !subdomain.isEmpty()
          && appId.length() > 0
          && !appId.isEmpty()
          && oauthClientId.length() > 0
          && !oauthClientId.isEmpty()) {
        LoggingUtil.d("Enabling Zendesk");
        ZendeskConfig.INSTANCE.init(this, subdomain, appId, oauthClientId);

        Identity identity = new AnonymousIdentity.Builder().build();
        ZendeskConfig.INSTANCE.setIdentity(identity);
      } else {
        LoggingUtil.e(
            "Spil Zendesk Module initialisation failed! Please make sure you include all the necessary information in the 'defaultGameConfig.json' file (subdomain, appId and oauthClientId). ");
      }

    } catch (NoClassDefFoundError error) {
      LoggingUtil.e(
          "Spil Zendesk Module not included! If you want to use zendesk please include the spilsdk-zendesk dependency");
    } catch (NullPointerException error) {
      LoggingUtil.e(
          "Spil Zendesk Module initialisation failed! Please make sure you include all the necessary information in the 'defaultGameConfig.json' file (subdomain, appId and oauthClientId). ");
    }

    SpilSdk.resetContext();
  }