dexmaker: dexcache == null error
This issue from the old google code project: https://code.google.com/p/dexmaker/issues/detail?id=2 is still valid as of the released 1.2 version
Java.lang.IllegalArgumentException: dexcache == null (and no default could be found; consider setting the 'dexmaker.dexcache' system property)
at com.google.dexmaker.DexMaker.generateAndLoad(DexMaker.java:359)
at com.google.dexmaker.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:252)
at com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:51)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:41)
...
However, I verified that it has been fixed in the current github repository (last commit March 12th 2015 - ca74669):
- git clone https://github.com/crittercism/dexmaker.git
- cd dexmaker
- mvn install -Dmaven.test.skip=true
- cp -R ~/.m2/repository/com/google/dexmaker $ANDROID_HOME/extras/android/m2repository/com/google
- and then update project dependency to 1.3-SNAPSHOT
It would be nice to have a 1.3 release so that we can take the workaround lines out of the test setUp() methods: System.setProperty(“dexmaker.dexcache”, getContext().getCacheDir().getPath());
Thanks!
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 15 (3 by maintainers)
@mjohenneken Thanks! Adding the
dexmaker-dx
dependency worked for me. 👍Hey guys I found a workaround for this that works:
https://comadeblog.wordpress.com/2013/11/12/dexcachenull-for-mockito-on-robolectric/comment-page-1/
Basically use 1.9 version of Mockito:
compile 'org.mockito:mockito-core:1.9.0'
Newer versions of mockito (I think since mockito 2.6) support android out of the box. You can remove all the dexmaker dependencies and add the mockito-android instead. Check out the android-boilerplate project for an example: https://github.com/ribot/android-boilerplate/blob/master/app/build.gradle