title: Error "Method isEmpty in android.text.TextUtils not mocked" when using PowerMockito.spy
body: <p>I use Mockito and PowerMock for local Unit tests in my Android app:</p>
  
  <pre><code>testImplementation 'org.mockito:mockito-core:2.8.9'
  
  String powerMockVersion = "1.7.3"
  testImplementation "org.powermock:powermock-module-junit4:${powerMockVersion}"
  testImplementation "org.powermock:powermock-api-mockito2:${powerMockVersion}"
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p><strong>MyTextUtils.java</strong></p>
  
  <pre><code>package sample.com.sample_app;
  
  import android.support.annotation.Nullable;
  import android.text.TextUtils;
  
  public class MyTextUtils {
  
      private MyTextUtils() {
          throw new AssertionError();
      }
  
      public static boolean isEmpty(@Nullable final CharSequence cs) {
          return TextUtils.isEmpty(cs);
      }
  }
  </code></pre>
  
  <p><strong>SystemUtils.java</strong></p>
  
  <pre><code>package sample.com.sample_app;
  
  import java.util.Random;
  
  public class SystemUtils {
  
      private SystemUtils() {
          throw new AssertionError();
      }
  
      public static long currentTimeMillis() {
          return System.currentTimeMillis();
      }
  
      public static long nextLong() {
          return new Random().nextLong();
      }
  }
  </code></pre>
  
  <p>And my tests.</p>
  
  <p><strong>FooTest.java</strong></p>
  
  <pre><code>package sample.com.sample_app;
  
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.powermock.api.mockito.PowerMockito;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.modules.junit4.PowerMockRunner;
  
  import static org.junit.Assert.assertEquals;
  
  @RunWith(PowerMockRunner.class)
  @PrepareForTest(SystemUtils.class)
  public class FooTest {
  
      @Before
      public void setUp() {
          PowerMockito.spy(SystemUtils.class);
          PowerMockito.when(SystemUtils.currentTimeMillis()).thenReturn(1_000L);
      }
  
      @Test
      public void foo() {
          assertEquals(1_000L, SystemUtils.currentTimeMillis());
      }
  }
  </code></pre>
  
  <p><strong>LoremIpsumTest.java</strong></p>
  
  <pre><code>package sample.com.sample_app;
  
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.powermock.api.mockito.PowerMockito;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.modules.junit4.PowerMockRunner;
  
  import static org.junit.Assert.assertTrue;
  
  @RunWith(PowerMockRunner.class)
  @PrepareForTest(MyTextUtils.class)
  public class LoremIpsumTest {
  
      @Before
      public void setUp() {
          PowerMockito.spy(MyTextUtils.class);
          PowerMockito.when(MyTextUtils.isEmpty("")).thenReturn(true);
      }
  
      @Test
      public void lorem() {
          assertTrue(MyTextUtils.isEmpty(""));
      }
  }
  </code></pre>
  
  <p>When I run <code>LoremIpsumTest</code>, it fails with the following error:</p>
  
  <pre><code>java.lang.RuntimeException: Method isEmpty in android.text.TextUtils not mocked. See http://g.co/androidstudio/not-mocked for details.
  </code></pre>
  
  <p>If I replace <code>PowerMockito.spy(MyTextUtils.class);</code> with <code>PowerMockito.mockStatic(MyTextUtils.class);</code>, <code>LoremIpsumTest</code> works.</p>
  
  <p>On the other hand, <code>FooTest</code> works with <code>PowerMockito.spy(SystemUtils.class);</code>. What's wrong with the partial mocking thing in <code>LoremIpsumTest</code>?</p>