Android Espresso multidex fail
<p>We use multidex in our app for a long time but recently with latest update it fails on android API &lt;19
e.g. emulator with api 16 
It is standard   java.lang.NoClassDefFoundError.</p>

<p>If I define multidexKeepProguard for missing class e.g.
 java.lang.NoClassDefFoundError. rx.plugins.RxJavaHooks exception</p>

<pre><code>-keep class rx.plugins.**{*;}
</code></pre>

<p>then it will just fail in a <strong><em>different place</em></strong> with the same reason NoClassDefFound </p>

<p>Here is the runner, app and manifest setup:</p>

<p><a href="https://gist.github.com/originx/1890599b57b0ee3e14a85a4732301cd9" rel="noreferrer">https://gist.github.com/originx/1890599b57b0ee3e14a85a4732301cd9</a></p>

<p>Logcat:</p>

<p><a href="https://gist.github.com/originx/887f80d405334f1903b3024eb5cd1024" rel="noreferrer">https://gist.github.com/originx/887f80d405334f1903b3024eb5cd1024</a></p>

<p>Build enviroment setup:</p>

<p>Android Studio 2.2.2
Build #AI-145.3360264, built on October 18, 2016
JRE: 1.8.0_112-release-b05 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o</p>

<p>Compile options</p>

<pre><code>compile 'com.android.support:multidex:1.0.1'
</code></pre>

<p>build tools info:</p>

<pre><code>   classpath 'com.android.tools.build:gradle:2.2.2'
   compileSdkVersion 25
   buildToolsVersion '25'


   defaultConfig {
        applicationId "app.packagename.com"

         minSdkVersion 16
        targetSdkVersion 25

        testInstrumentationRunner "de.payback.app.CustomAndroidJUnitRunner"
        multiDexEnabled true
    }

 dexOptions {
        jumboMode true
        preDexLibraries false
        javaMaxHeapSize "4g"
        maxProcessCount = 8
    }

  debug {
            applicationIdSuffix '.debug'
            versionNameSuffix '-debug'
            signingConfig signingConfigs.debug
            minifyEnabled false
            shrinkResources debugShrinkResourcesEnabled
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguardRules/proguard-rules.pro', '../proguardRules/proguard-debug-rules.pro'
          //  multiDexKeepProguard file('../proguardRules/multidex-proguard.pro')
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguardRules/proguard-rules.pro', '../proguardRules/proguard-debug-test-rules.pro'
            testCoverageEnabled false
        }
        release {
            minifyEnabled true
            shrinkResources true
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguardRules/proguard-rules.pro'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguardRules/proguard-rules.pro'
          //  multiDexKeepProguard file('../proguardRules/multidex-proguard.pro')
        }
</code></pre>

<p>I tried everything from extending MultiDexApplication, to custom MultiDex.install(context) to using MultiDexRunner</p>

<p>same results always</p>

<p>if using multidexkeepproguard file for classes which are usually not found then they are in main dex file but of course something else is missing which indicates that multidex was not properly installed and initialized</p>

<p>Google bug report:</p>

<p><a href="https://code.google.com/p/android/issues/detail?id=228449" rel="noreferrer">https://code.google.com/p/android/issues/detail?id=228449</a></p>

<p>repo to reproduce the issue can be found here:</p>

<p><a href="https://github.com/originx/multidex/tree/master" rel="noreferrer">https://github.com/originx/multidex/tree/master</a></p>

<p>To run please disable instant run</p>

<p>To reproduce multidex issue please run following command</p>

<p><code>./gradlew clean connectedPayGermanyCompatDebugAndroidTest</code> </p>

<p>run on any device or API 16 emulator Tests on GTI8190 4.1.2 failed Instrumentation run failed due to java.lang.NoClassDefFoundError</p>

<p>Any suggestions how to work around this until I get more info from the Google team?</p>