question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with abstract method after updating from Mockito 1.9.5 to 2.8.9

See original GitHub issue

I am having an issue when trying to spy an object after moving from Mockito 1.9.5 to 2.8.9

when I use gradlew to look at all my dependencies, i do not see any old versions of Mockito hanging around as you mentioned in a previous post with a nearly identical call stack. Cleaned, resync’d Android Studio, etc.

Do I need to implement the missing abstract method? If no, then what else could be the issue here? I always assume that I’m doing something wrong.

From my build.gradle

    compile ('org.mockito:mockito-core:2.8.9') {
         exclude module: 'objenesis'
         exclude group: 'org.objenesis', module: 'objenesis'
    }
   compile 'com.google.dexmaker:dexmaker-mockito:1.2'`

Snip of code where this is happening. (works ok in 1.9.5, but not 2.x.x)

ConnectivityManager origCm = (ConnectivityManager)super.getSystemService(name);
ConnectivityManager connectivityManager = Mockito.spy(origCm);

java.lang.AbstractMethodError: abstract method “org.mockito.plugins.MockMaker$TypeMockability org.mockito.plugins.MockMaker.isTypeMockable(java.lang.Class)” at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29) at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22) at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:186) at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180) at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62) at org.mockito.Mockito.spy(Mockito.java:1812) at example.com.myclient.MyMainApp.getSystemService(MyMainApp.java:114) at com.scrubbed.android.sdk.net.VocAccelerator.init(VocAccelerator.java:96) at com.scrubbed.android.sdk.VocService.createVocService(VocService.java:143) at com.scrubbed.vocsdkliveapitestlib.SdkLiveTest_BaseServiceTest.setSomeService(SdkLiveTest_BaseServiceTest.java:217) at com.scrubbed.vocsdkliveapitestlib.SdkLiveTest_BaseServiceTest.unRegisterIfNecessary(SdkLiveTest_BaseServiceTest.java:166) at com.scrubbed.vocsdkliveapitestlib.SdkLiveTest_BaseServiceTest.waitForSyncToFinishAndThenDeregister(SdkLiveTest_BaseServiceTest.java:211) at com.scrubbed.vocsdkliveapitestlib.SdkLiveTest_BaseServiceTest.unRegisterIfNecessary(SdkLiveTest_BaseServiceTest.java:151) at com.scrubbed.vocsdkliveapitestlib.SdkLiveTest_BaseServiceTest.setUp(SdkLiveTest_BaseServiceTest.java:41) at com.scrubbed.android.sdk.internal.MapLT_AICTests.setUp(MapLT_AICTests.java:77) at junit.framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:115) at android.support.test.internal.runner.junit3.AndroidTestResult.runProtected(AndroidTestResult.java:77) at junit.framework.TestResult.run(TestResult.java:118) at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:55) at junit.framework.TestCase.run(TestCase.java:124) at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63) at junit.framework.TestSuite.runTest(TestSuite.java:243) at junit.framework.TestSuite.run(TestSuite.java:238) at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103) at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:69) at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:103) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59) at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1873) `

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mikelupocommented, Jul 18, 2017

Problem solved. Cleaned again, this time deleted .gradle folder in the root of the project and resync’d rebuilt. Root of the problem was that at one time we were trying out PowerMock. Gradle don’t quite make the “Grade”.

Closing.

If anyone is hitting these same problems, it’s definitely due to incorrect versions of Mockito being references from elsewhere.

0reactions
mikelupocommented, Jul 18, 2017

Still an issue with PowerMockMaker. Strange. Seems like I still have more cleaning to do, but not sure how…

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:66)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy0.isTypeMockable(Unknown Source)
at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:186)
at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
at org.mockito.Mockito.spy(Mockito.java:1812)
at example.com.mapclient.MapMainApp.getSystemService(MapMainApp.java:114)
at com.akamai.android.sdk.net.VocAccelerator.init(VocAccelerator.java:96)
at com.akamai.android.sdk.VocService.createVocService(VocService.java:143)
at com.akamai.vocsdkliveapitestlib.VocSdkLiveTest_BaseServiceTest.setVocService(VocSdkLiveTest_BaseServiceTest.java:217)
at com.akamai.vocsdkliveapitestlib.VocSdkLiveTest_BaseServiceTest.unRegisterIfNecessary(VocSdkLiveTest_BaseServiceTest.java:166)
at com.akamai.vocsdkliveapitestlib.VocSdkLiveTest_BaseServiceTest.waitForSyncToFinishAndThenDeregister(VocSdkLiveTest_BaseServiceTest.java:211)
at com.akamai.vocsdkliveapitestlib.VocSdkLiveTest_BaseServiceTest.unRegisterIfNecessary(VocSdkLiveTest_BaseServiceTest.java:151)
at com.akamai.vocsdkliveapitestlib.VocSdkLiveTest_BaseServiceTest.setUp(VocSdkLiveTest_BaseServiceTest.java:41)
at com.akamai.android.sdk.internal.MapLT_AICTests.setUp(MapLT_AICTests.java:77)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at android.support.test.internal.runner.junit3.AndroidTestResult.runProtected(AndroidTestResult.java:77)
at junit.framework.TestResult.run(TestResult.java:118)
at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:55)
at junit.framework.TestCase.run(TestCase.java:124)
at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)
at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:69)
at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:103)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1873)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.TwoEnumerationsInOne@d0d67a8
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:101)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:45)
at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:18)
at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:17)
at org.mockito.internal.configuration.plugins.Plugins.getMockMaker(Plugins.java:33)
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
... 39 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.powermock.api.mockito.internal.mockmaker.PowerMockMaker" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/example.com.mapclient.test-1/base.apk", zip file "/data/app/example.com.mapclient-2/base.apk"],nativeLibraryDirectories=[/data/app/example.com.mapclient-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:95)
... 44 more
Suppressed: java.lang.ClassNotFoundException: org.powermock.api.mockito.internal.mockmaker.PowerMockMaker
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 46 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Read more comments on GitHub >

github_iconTop Results From Across the Web

Mockito 2.8.9 API - javadoc.io
Mockito verifies argument values in natural java style: by using an equals() method. Sometimes, when extra flexibility is required then you might use...
Read more >
changelog.txt - Google Git
* This allows creating mocks in the applyInterceptionPolicy method of MockPolicy, which in turn allows using MockPolicy together with PowerMockRule (issue 581).
Read more >
PowerMock throws NoSuchMethodError (setMockName)
I've traced the dependency tree of my project and fixed conflicts so that mockito-all:1.9.5 gets included in the build. java · mockito ·...
Read more >
Change log - GitHub
Previously when PowerMock was used with class which works with XML adding ... Mockito extension API now uses Mockito 1.9.5 (issue 398) *...
Read more >
Testing an Abstract Class With JUnit - Baeldung
Learn about specifics of unit testing abstract classes, ... of the mock to use the real code when a method is invoked using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found