title: How to mock Base64 in Android?
body: <p>I am writing a Unit test for a class that uses <code>android.util.Base64</code> and I get this error:</p>
  
  <pre><code>java.lang.RuntimeException: Method encode in android.util.Base64 not mocked. See http://g.co/androidstudio/not-mocked for details.
  at android.util.Base64.encode(Base64.java)
  </code></pre>
  
  <p>This is the code using the <code>encode()</code> method:</p>
  
  <pre><code>ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  // [write some data to the stream]
  byte[] base64Bytes = Base64.encode(byteArrayOutputStream.toByteArray(), Base64.DEFAULT);
  </code></pre>
  
  <p>Now I understand that I can't use Android library classes in my Unit tests. But how do I correctly mock <code>Base64</code> so I can write a correct Unit test for my class?</p>