title: java.lang.LinkageError: MainActivity
body: <p>I use <code>productFlavours</code> in my app. 
  I'm also using multi dex.</p>
  
  <pre><code> defaultConfig {
           multiDexEnabled true
           minSdkVersion 17
           targetSdkVersion 22
           ... 
   }
  
  productFlavors {
    prodFlavor1{...}
    prodFlavor2{...}
   }
  
  dependencies {
      compile 'com.android.support:multidex:1.0.1'
  ...
  }
  </code></pre>
  
  <p>In the Application class:</p>
  
  <pre><code>@Override
      public void onCreate() {
          MultiDex.install(getApplicationContext());
          super.onCreate();
  }
  </code></pre>
  
  <p>I have added the above code for Android versions below 5 support.</p>
  
  <p>Then the following structure, with 2 slightly different versions of <code>MainActivity</code> (MainActivity extends AppCompatActivity) starts at a certain moment in the app, on a button press.</p>
  
  <pre><code>app/src/prodFlavor1/.../MainActivity
  app/src/prodFlavor2/.../MainActivity
  </code></pre>
  
  <p>In <code>prodFlavor1</code>, <code>MainActivity</code> starts immediately after <code>SplashActivity</code>.
  In <code>prodFlavor2</code>, <code>MainActivity</code>.</p>
  
  <p>This worked for a long period before and even after I added that part with <code>multidex</code>, but suddenly stooped working with no explanation. Even if I remove the code referencing multidex, I get the same thing.</p>
  
  <p>When I switch to <code>prodVersion2</code> everything works. But when I switch to <code>prodVersion1</code> I get:</p>
  
  <p><code>startActivity(new Intent(TutorialActivity.this,MainActivity.class));</code></p>
  
  <p><strong>Nexus 5 with Android 6:</strong></p>
  
  <pre><code>Process: com.mpackage, PID: 30807
                                                               java.lang.LinkageError: com.mpackage.activities.MainActivity
                                                                   at dalvik.system.DexFile.defineClassNative(Native Method)
                                                                   at dalvik.system.DexFile.defineClass(DexFile.java:226)
                                                                   at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
                                                                   at dalvik.system.DexPathList.findClass(DexPathList.java:338)
                                                                   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
                                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                   at com.gossip.activities.TutorialActivity$1.handleMessage(TutorialActivity.java:52)
                                                                   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)
  </code></pre>
  
  <p><strong>On Nexus4 Emulator with Android 4.4:</strong></p>
  
  <pre><code>java.lang.NoClassDefFoundError: com.mpackage.activities.MainActivity
                                                                 at com.gossip.activities.TutorialActivity$1.handleMessage(TutorialActivity.java:52)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                 at android.os.Looper.loop(Looper.java:136)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                                 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:779)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                 at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Seems that the error was caused by the fact that I have added a method called <code>isResumed()</code> in <code>MainActivity</code>, that's why <code>(Native Method)</code> error, different on 6.0 from 4.4.</p>