Robolectric = Mockito : Cannot Create Mock or Spy In Mockito Because: dexcache == null
<p>I have a well reported issue here:</p>

<p><a href="https://stackoverflow.com/questions/12267572/mockito-dexmaker-on-android">Mockito + Dexmaker on Android</a></p>

<p>However the solution does not work.</p>

<p>I am using Robolectric and even when I try setting the dexmaker cache location:</p>

<pre><code>@Before
public void setUp()
{
    System.setProperty("dexmaker.dexcache", RuntimeEnvironment.application.getCacheDir().getPath());
}
</code></pre>

<p>The error changes to</p>

<p>java.lang.RuntimeException: java.lang.NullPointerException</p>

<pre><code>at com.android.dx.DexMaker.generateClassLoader(DexMaker.java:366)
at com.android.dx.DexMaker.generateAndLoad(DexMaker.java:439)
at com.android.dx.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:264)
at com.android.dx.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:56)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
at org.mockito.Mockito.spy(Mockito.java:1368)
</code></pre>

<p>Do you have any ideas that will enable me to create Mock or Spy objects using Robolectric? </p>

<p>Note: When I don't use Robolectric and use a regular <code>ActivityInstrumentationTestCase2</code> and <code>@RunWith(AndroidJUnit4.class)</code> I can create Mock and Spy objects...</p>

<p>This issue has arisen after Mockito 1.9</p>