Search code examples
androidruntimeandroid-multidex

Crash - Runtime exception (MultiDex.java:178)


I have a issue with application class, is a Runtime exception so I can't find how replicate, maybe some people here can help me with this problem. I think that maybe is the device or android in self, but I need to be sure, if anyone can help me, i going to be grateful. Thanks and sorry for my bad english.

Android version: 4.4 Stacktrace:

java.lang.RuntimeException: at android.app.LoadedApk.makeApplication (LoadedApk.java:516) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4514) at android.app.ActivityThread.access$1500 (ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1381) at android.os.Handler.dispatchMessage (Handler.java:110) at android.os.Looper.loop (Looper.java:193) at android.app.ActivityThread.main (ActivityThread.java:5299) at java.lang.reflect.Method.invokeNative (Native Method) at java.lang.reflect.Method.invoke (Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:825) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:641) at dalvik.system.NativeStart.main (Native Method)

Caused by: java.lang.RuntimeException: at android.support.multidex.MultiDex.install (MultiDex.java:178) at app.tacoguru.MultiDexApplication.attachBaseContext (MultiDexApplication.java:35) at android.app.Application.attach (Application.java:181) at android.app.Instrumentation.newApplication (Instrumentation.java:991) at android.app.Instrumentation.newApplication (Instrumentation.java:975) at android.app.LoadedApk.makeApplication (LoadedApk.java:511)

MultidexApplication code lines:

public class MultiDexApplication extends Application {

    public MultiDexApplication() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Apptentive.register(this, key);
    }

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

    @Override
    public Context getApplicationContext() {
        return super.getApplicationContext();
    }
}

Manifest:

<application
    android:name=".MultiDexApplication"
    android:allowBackup="true"
    android:hardwareAccelerated="true"
    android:icon="@mipmap/ic_launcher"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

gradle:

defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        multiDexEnabled true 
}

Solution

  • Try removing this line MultiDex.install(this); and inherit your Application class from MultiDexApplication instead of Application.