Skip to content

Instrumented tests crash with AndroidJUnitRunner not being found on classpath on Android 8.0 emulator #126

@matejdro

Description

@matejdro

Steps to reproduce the bug:

  1. Open TestProject.zip
  2. Run included ExampleInstrumentedTest test
  3. Tests will crash with following exception (in Logcat)
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.matejdro.testproject, PID: 15073
    java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.matejdro.testproject.test/android.support.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5730)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5728)
        at android.app.ActivityThread.-wrap1(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

When removing testInstrumentationRunnerArgument line and everything JUnit5-related from dependencies, tests start working again

What I did to create this test project:

  1. Create new Android project with Kotlin support and no activity
  2. Bump gradle version to 4.7 to allow plugin to work
  3. Copy paste all instrumented test gradle stuff from README to the gradle file

So it is basically bare minimum that is supposed to work. Am I doing something wrong here or is this a bug?

If it helps, I reproduced this on Nexus 5X x86 emulator with Android 8.0 (Google Play) System image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions