Is it possible to use dexmaker-mockito-inline on API <28?
Hi,
I need dexmaker-mockito-inline to run tests on Android 9.0, but I still want to run tests on older apis. Currently I have this error:
Caused by: java.io.IOException: Requires API level 28. API level is 23
Is there a way to run tests on different API without changing gradle dependencies which is not quite convenient?
dexmaker-mockito-inline just does not work before API 28. There is no fall back or anything.
You have to use dexmaker-mockito but they you cannot stub final methods.
Some people though about extending dexmaker-mockito-inline with class loader tricks to work for most classes on older platforms, but this is not implemented yet.
In my case the problem is with hidden api spying and mocking which does not work on Android P.
Can you give an example what you are trying to do. Beside the test and simplified app code, can you also describe what device you are running on?
I'm spying ApplicationPackageManager which is hidden. It works well on api <28 with dexmaker-mockito, on 28 it works with dexmaker-mockito-inline
I think I could be possible to provide proxy MockMaker which initialize MockMakerMultiplexer or DexmakerMockMaker based on system api version - this would sove the problem with hidden api but of course not with final methods. However mocking final methods hisorically is not common to mockito.
dexmaker-mockito in the latest version should be able to deal with hidden methods.
I need the test, the gradle file and the test log to debug the issue.
Check this project https://github.com/lsuski/dexmaker-hidden-api-test and ExampleInstrumentedTest