Search code examples
androidstack-overflowandroid-multidex

Android StackOverflow error on enabling MultiDex


I'm getting the following exception after enabling MultiDex. My custom Application class is as follows.

public class PFApplication extends SugarApp {
   @Override
   public void onCreate() {
       super.onCreate();
       Branch.getAutoInstance(this);
   }

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

}

And given below is the stacktrace. App crashes on launch.

FATAL EXCEPTION: main Process: com.riverviewcs.product.friend, PID: 26404 java.lang.StackOverflowError at android.content.ContextWrapper.getPackageManager(ContextWrapper.java:100) ......

Any idea why?


Solution

  • You are getting this error

    java.lang.StackOverflowError at android.content.ContextWrapper.getPackageManager

    StackOverflowError

    Thrown when a stack overflow occurs because an application recurses too deeply.

    You should rectify your attachBaseContext section .

    FYI

    Call base instead of this

    super.attachBaseContext(base);