title: Mockito + Dexmaker on Android 2
body: <p>I saw this question:
  <a href="https://stackoverflow.com/questions/12267572/mockito-dexmaker-on-android">Mockito + Dexmaker on Android</a></p>
  
  <p>And after the using the answer I came into another problem:
  java.lang.RuntimeException: java.lang.IllegalArgumentException: Optimized data directory /sdcard is not owned by the current user. Shared storage cannot protect your application from code injection attacks.</p>
  
  <p>I use the latest version of mockito and dexmaker and dexmaker-mockito.</p>
  
  <p>I'm using a separate testproject.</p>
  
  <p>Full stacktrace (testParse is my test function):</p>
  
  <pre><code>java.lang.RuntimeException: java.lang.IllegalArgumentException: Optimized data directory /sdcard is not owned by the current user. Shared storage cannot protect your application from code injection attacks.
  at com.google.dexmaker.DexMaker.generateAndLoad(DexMaker.java:388)
  at com.google.dexmaker.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:252)
  at com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:54)
  at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
  at org.mockito.internal.MockitoCore.mock(MockitoCore.java:49)
  at org.mockito.Mockito.mock(Mockito.java:1245)
  at org.mockito.Mockito.mock(Mockito.java:1139)
  at com.myproject.parser.JSONParserTest.testParse(JSONParserTest.java:29)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
  Caused by: java.lang.IllegalArgumentException: Optimized data directory /sdcard is not owned by the current user. Shared storage cannot protect your application from code injection attacks.
  at dalvik.system.DexFile.&lt;init&gt;(DexFile.java:100)
  at dalvik.system.DexFile.loadDex(DexFile.java:149)
  at dalvik.system.DexPathList.loadDexFile(DexPathList.java:259)
  at dalvik.system.DexPathList.makeDexElements(DexPathList.java:223)
  at dalvik.system.DexPathList.&lt;init&gt;(DexPathList.java:106)
  at dalvik.system.BaseDexClassLoader.&lt;init&gt;(BaseDexClassLoader.java:46)
  at dalvik.system.DexClassLoader.&lt;init&gt;(DexClassLoader.java:57)
  at java.lang.reflect.Constructor.constructNative(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
  at com.google.dexmaker.DexMaker.generateAndLoad(DexMaker.java:382)
  ... 19 more
  </code></pre>