【发布时间】:2014-12-29 02:22:00
【问题描述】:
我正在尝试在我的项目(具有多个 Android 库项目)上运行 roboelectric,但当我尝试使用简单的字符串检查运行测试项目时,我不断收到此错误。
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 在 org.robolectric.bytecode.RobolectricInternals.newInstanceOf(RobolectricInternals.java:33) 在 org.robolectric.Robolectric.newInstanceOf(Robolectric.java:348) 在 org.robolectric.Robolectric.newInstanceOf(Robolectric.java:355) 在 org.robolectric.shadows.ShadowApplication.registerBroadcastReceivers(ShadowApplication.java:121) 在 org.robolectric.shadows.ShadowApplication.bind(ShadowApplication.java:110) 在 org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:136) 在 org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:430) 在 org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:236) 在 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 在 org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:300) 在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 在 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 引起:java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:526) 在 org.robolectric.bytecode.RobolectricInternals.newInstanceOf(RobolectricInternals.java:25)
【问题讨论】:
-
java.lang.NoSuchMethodError: android.util.Log.secD(Ljava/lang/String;Ljava/lang/String;) 库依赖版本不匹配?
-
谢谢@almasshaikh 我明白了。
-
好的,所以我会把它作为答案发布,所以如果有人得到相同的结果,他们会稍后参考而不是阅读 cmets。
标签: android junit robolectric android-testing