Search code examples
androidandroid-gradle-pluginandroid-instrumentation

Multi-module MultiDex project won't run tests after update to android gradle plugin 2.3


I have project with multiple modules, all of which are configured to build with multiDexEnabled true. All of these modules have instrumentation test packages that are configured to run JUnit4 tests with MultiDex enabled per this SO answer: https://stackoverflow.com/a/35214158/736963 EXCEPT for one of the modules. One of the modules is configured to use testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner" (and hence has no JUnit4 tests) because it depends on a DLL that just will not load with the JUnit4 test runner. (If anyone knows the solution to that one, that's great! But that's not the problem I'm reporting here...)

This configuration has been working fine until I just attempted to update to android gradle plugin 2.3.0. Now when I run tests for the module using the JUnit3 MultiDexTestRunner, I see this:

Started running tests
Test running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
Empty test suite.

And in the console this (truncated to the useful bit):

java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.redacted.test/com.android.test.runner.MultiDexTestRunner}: java.lang.ClassNotFoundException: Didn't find class "com.android.test.runner.MultiDexTestRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.redacted.test-1/base.apk", zip file "/data/app/com.redacted.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.redacted.test-1/lib/arm, /data/app/com.redacted.test-1/lib/arm, /data/app/com.redacted.test-1/base.apk!/lib/armeabi-v7a, /data/app/com.redacted.test-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.test.runner.MultiDexTestRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.intuit.paymentshub.test-1/base.apk", zip file "/data/app/com.intuit.paymentshub.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.intuit.paymentshub.test-1/lib/arm, /data/app/com.intuit.paymentshub.test-1/lib/arm, /data/app/com.intuit.paymentshub.test-1/base.apk!/lib/armeabi-v7a, /data/app/com.intuit.paymentshub.test-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

So I'm stuck on the earlier Android Gradle Plugin until I can resolve this (or the DLL problem, though I'm less hopeful on that one since it has never worked.)


Solution

  • It seems like this problem went away after updating the tooling. Currently running android for gradle 2.3.3 with buildTools 26 and this problem is gone.