Roboelectric java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

Issue

I’m trying to run roboelectric on my project (with multiple Android library projects) and i keep getting this error when i try running the test project with a simple string check.

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.robolectric.bytecode.RobolectricInternals.newInstanceOf(RobolectricInternals.java:33) at org.robolectric.Robolectric.newInstanceOf(Robolectric.java:348) at org.robolectric.Robolectric.newInstanceOf(Robolectric.java:355) at org.robolectric.shadows.ShadowApplication.registerBroadcastReceivers(ShadowApplication.java:121) at org.robolectric.shadows.ShadowApplication.bind(ShadowApplication.java:110) at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:136) at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:430) at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:236) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.robolectric.bytecode.RobolectricInternals.newInstanceOf(RobolectricInternals.java:25)

Solution

java.lang.NoSuchMethodError: android.util.Log.secD(Ljava/lang/String;Ljava/lang/String;) Is the error that you are getting.

It seems you have library (dependency) version mismatch?

Answered By – SMA

Leave a Comment