Android API 19上的NoClassDefFoundError ObjenesisStd

时间:2017-03-02 01:36:54

标签: android mockito dexmaker

我仅在运行API v19的模拟器上进行检测测试时发生以下崩溃。如果我在新版本上运行,一切正常。

  

03-01 20:26:18.781 2878-2878 /? E / MonitoringInstrumentation:异常   遇到者:Thread [main,5,main]。将线程状态转储到输出   并为峡湾而苦恼。                                                               java.lang.NoClassDefFoundError:org.objenesis.ObjenesisStd                                                                   在org.mockito.internal.creation.jmock.ClassImposterizer。(ClassImposterizer.java:36)                                                                   在org.mockito.internal.creation.jmock.ClassImposterizer。(ClassImposterizer.java:29)                                                                   在org.mockito.internal.util.MockCreationValidator.isTypeMockable(MockCreationValidator.java:17)                                                                   在org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:21)                                                                   在org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:133)                                                                   在org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:127)                                                                   在org.mockito.internal.MockitoCore.mock(MockitoCore.java:50)                                                                   在org.mockito.Mockito.mock(Mockito.java:1243)                                                                   在org.mockito.Mockito.mock(Mockito.java:1120)

问题在于这一行:

  

java.lang.NoClassDefFoundError:org.objenesis.ObjenesisStd

我的应用程序是多语言,我使用dexmaker-mockito进行androidTestCompile。我完全失去了为什么这只会破坏旧的API。当我向我的项目中添加另一个模块时,它开始发生了,这是一个纯粹的java模块,不依赖于mockito。

1 个答案:

答案 0 :(得分:0)

此异常( ClassNotFoundException )告诉您运行时的 unmet 依赖关系:JVM需要加载一个类;这在课程路径中不存在。

这是Mockito需要Objenesis。通常,当您使用maven这样的系统时,应该自动提取该库,并为Mockito提供正确的依赖关系。