We started using Espresso 2.0 + Cucumber to run automation tests for our application.
Recently we tried to run the automation on a device with Android version 4.4 and it crashed.
The exception we get is: Test running failed: Instrumentation run failed due to 'java.lang.IllegalStateException'
With an Android device which running version 5.0 (Lollipop) it works perfectly fine.
We tried 3 different Android 4.4 devices and all of them crashed.
I tried to run a simple automation without CucumberInstrumentationCore and it worked with all the devices.
So, there is a bug in the CucumberInstrumentationCore which fail to launch on some versions of Android?
03-24 14:35:07.351 1019-1351/? E/ActivityManager: App crashed! Process:
com.example.app03-24 14:35:07.351 22538-22538/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at java.lang.Class.getDeclaredConstructors(Native Method)
at java.lang.Class.getConstructors(Class.java:508)
at cucumber.runtime.java.picocontainer.PicoFactory.addConstructorDependencies(PicoFactory.java:39)
at cucumber.runtime.java.picocontainer.PicoFactory.addClass(PicoFactory.java:30)
at cucumber.runtime.android.AndroidObjectFactory.addClass(AndroidObjectFactory.java:52)
at cucumber.runtime.java.JavaBackend.addHook(JavaBackend.java:137)
at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:66)
at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:41)
at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:78)
at cucumber.runtime.Runtime.<init>(Runtime.java:90)
at cucumber.runtime.Runtime.<init>(Runtime.java:68)
at cucumber.runtime.android.CucumberExecutor.<init>(CucumberExecutor.java:92)
at cucumber.api.android.CucumberInstrumentationCore.create(CucumberInstrumentationCore.java:70)
at com.example.app.helpers.Instrumentation.onCreate(Instrumentation.java:16)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4912)
at android.app.ActivityThread.access$1500(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
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:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
at android.support.test.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)
at android.support.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:108)
at android.support.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:86)
at android.support.test.rule.ActivityTestRule.<init>(ActivityTestRule.java:67)
at com.example.app.stepDefinitions.BaseSteps.<clinit>(BaseSteps.java:18)
at java.lang.Class.getDeclaredConstructors(Native Method)
at java.lang.Class.getConstructors(Class.java:508)
at cucumber.runtime.java.picocontainer.PicoFactory.addConstructorDependencies(PicoFactory.java:39)
at cucumber.runtime.java.picocontainer.PicoFactory.addClass(PicoFactory.java:30)
at cucumber.runtime.android.AndroidObjectFactory.addClass(AndroidObjectFactory.java:52)
at cucumber.runtime.java.JavaBackend.addHook(JavaBackend.java:137)
at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:66)
at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:41)
at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:78)
at cucumber.runtime.Runtime.<init>(Runtime.java:90)
at cucumber.runtime.Runtime.<init>(Runtime.java:68)
at cucumber.runtime.android.CucumberExecutor.<init>(CucumberExecutor.java:92)
at cucumber.api.android.CucumberInstrumentationCore.create(CucumberInstrumentationCore.java:70)
at com.example.app.helpers.Instrumentation.onCreate(Instrumentation.java:16)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4912)
at android.app.ActivityThread.access$1500(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
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:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Alonso.