解析Android中的LinkedList时的java.lang.AbstractMethodError

前端之家收集整理的这篇文章主要介绍了解析Android中的LinkedList时的java.lang.AbstractMethodError前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想窥探 android中的Linkedlist.
List list = new LinkedList();
List spyData = Mockito.spy(list);
spyData.add("xxxx");

但是,发生了异常.

java.lang.AbstractMethodError: abstract method "boolean org.mockito.internal.invocation.AbstractAwareMethod.isAbstract()"
    at     org.mockito.internal.invocation.InvocationImpl.callRealMethod(InvocationImpl.java:109)
    at org.mockito.internal.stubbing.answers.CallsRealMethods.answer(CallsRealMethods.java:41)
    at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:93)
    at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29)
    at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:38)
    at com.google.dexmaker.mockito.InvocationHandlerAdapter.invoke(InvocationHandlerAdapter.java:49)
    at LinkedList_Proxy.add(LinkedList_Proxy.generated)
    at com.app.test.testmethod(mytest.java:202)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
    at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1858)

libs的依赖关系是

dexmaker-1.2.jar
dexmaker-mockito-1.2.jar
mockito-core-1.10.19.jar

甚至我将mockito-core-1.10.19.jar更新为mockito-core-2.0.31-beta.jar,

问题依然存在.

但是Mockito.mock(Linkedlist.class)还可以,我对这个问题没有任何想法.

谢谢.

解决方法

我刚刚找到了解决问题的另一种方法.

对于dexmaker 1.2来说这是一个问题,我们应该升级到dexmaker 1.4,dexmaker-mockito 1.4并包含dexmaker-dx-1.4.

所以依赖是

dexmaker-dx-1.4.jar
dexmaker-1.4.jar
dexmaker-mockito-1.4.jar
mockito-core-1.10.19.jar

猜你在找的Android相关文章