title: Android Multidex RuntimeException
body: <p>I am trying to solve a problem with running Android app that has over 65k methods. 
  <br>I have followed Google docs about Multidex support, however I'm still unable to run it successfully. It seems that the problem appears only on SDK less than 21, because when I specify <code>minSdkVersion 21</code>, it works well, however once I set it to <code>minSdkVersion 15</code>, I am getting following exception.</p>
  
  <pre><code>FATAL EXCEPTION: main
     java.lang.RuntimeException: Unable to instantiate application custom.package.name.MyApplication: java.lang.ClassNotFoundException: Didn't find class "custom.package.name.MyApplication" on path: DexPathList[[zip file "/data/app/custom.package.name-2/base.apk"],nativeLibraryDirectories=[/data/app/custom.package.name-2/lib/arm, /vendor/lib, /system/lib]]
        at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  
     Caused by: java.lang.ClassNotFoundException: Didn't find class "custom.package.name.MyApplication" on path: DexPathList[[zip file "/data/app/custom.package.name-2/base.apk"],nativeLibraryDirectories=[/data/app/custom.package.name-2/lib/arm, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at android.app.Instrumentation.newApplication(Instrumentation.java:981)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680) 
        at android.app.ActivityThread.-wrap1(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
     Suppressed: java.io.IOException: Failed to open dex files from /data/app/custom.package.name-2/base.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:295)
        at dalvik.system.DexFile.&lt;init&gt;(DexFile.java:80)
        at dalvik.system.DexFile.&lt;init&gt;(DexFile.java:59)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
        at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
        at dalvik.system.DexPathList.&lt;init&gt;(DexPathList.java:120)
        at dalvik.system.BaseDexClassLoader.&lt;init&gt;(BaseDexClassLoader.java:48)
        at dalvik.system.PathClassLoader.&lt;init&gt;(PathClassLoader.java:65)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:376)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:568)
              ... 9 more
     Suppressed: java.lang.ClassNotFoundException: custom.package.name.MyApplication
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
              ... 12 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
  </code></pre>
  
  <p><strong>Logcat before fatal exception</strong></p>
  
  <pre><code>W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/custom.package.name-2/base.apk --oat-file=/data/dalvik-cache/arm/data@app@custom.package.name-2-2@base.apk@classes.dex) because non-0 exit status
  W/art: Failure to verify dex file '/data/app/ccustom.package.name-2-2/base.apk': Invalid method name: '_clinit@1433781298707#0'
  W/System: ClassLoader referenced unknown path: /data/app/custom.package.name-2-2/lib/arm
  </code></pre>
  
  <p>Here is what I've done so far:</p>
  
  <ul>
  <li><p><strong>created class called MyApplication that extends Application and specified it in AndroidManifest.xml file</strong></p></li>
  <li><p><strong>added dependency to build.gradle file</strong></p>
  
  <p><code>compile 'com.android.support:multidex:1.0.1'</code></p></li>
  <li><p><strong>enabled multidex in build.gradle</strong></p>
  
  <p><code>multiDexEnabled true</code></p></li>
  <li><p><strong>enabled multidex in MyApplication class</strong>
  <code>
  @Override
  protected void attachBaseContext(Context base) {
      super.attachBaseContext(base);
      MultiDex.install(this);
  }
  </code></p></li>
  </ul>
  
  <p>Thanks in advance for any help!</p>