title: java.lang.NoSuchMethodError: No static method clearInstance()
body: <p>I'm trying to run a test in Android Studio, the test setup is throwing an <strong>java.lang.NoSuchMethodError</strong></p>
  
  <p>Test:</p>
  
  <pre><code>@RunWith(AndroidJUnit4.class)
  @LargeTest
  public class MusicLocalDataSourceTest {
      private Context context;
      private final static String TITLE_1 = "TITLE 1";
      private final static String ID_1 = "1";
      private final static String ARTISTIC_1 = "ARTISTIC 1";
  
  
      private DataSource&lt;Music&gt; mMusicDataSource;
      private StapeDatabase mDatabase;
  
      @Before
      public void setup() {
          context = InstrumentationRegistry.getTargetContext();
          mDatabase = Room
                  .inMemoryDatabaseBuilder(context, StapeDatabase.class)
                  .build();
  
          IEMusicDao dao = mDatabase.musicDao();
  
          MusicLocalDataSource.clearInstance(); // throws error
          mMusicDataSource = MusicLocalDataSource.getInstance(new SingleExecutor(), dao);
      }
  
      @After
      public void cleanUp() {
          mDatabase.close();
          MusicLocalDataSource.clearInstance();
      }
  
      @Test
      public void should_not_have_null_instance() {
          assertNotNull(mMusicDataSource);
      }
  }
  
  classe que estou testando:
  class being tested:
  
  public class MusicLocalDataSource implements IEMusicDataSource&lt;Music&gt; {
      private static volatile MusicLocalDataSource INSTANCE;
      private IEMusicDao musicDao;
      private AppExecutors appExecutors;
  
      private MusicLocalDataSource(@NonNull AppExecutors appExecutors, @NonNull IEMusicDao musicDao) {
          this.appExecutors = appExecutors;
          this.musicDao = musicDao;
      }
  
      public static MusicLocalDataSource getInstance(@NonNull AppExecutors appExecutors, @NonNull
                                                     IEMusicDao musicDao) {
  
          if (INSTANCE ==  null) {
              synchronized (MusicLocalDataSource.class) {
                  if (INSTANCE == null) {
                      INSTANCE = new MusicLocalDataSource(appExecutors, musicDao);
                  }
              }
          }
  
          return INSTANCE;
      }
  
      @Override
      public void findAll(@NonNull LoadDataCallback&lt;Music&gt; callback) {
          Runnable runnable = () -&gt; {
            final List&lt;Music&gt; musics = musicDao.findAll();
            this.appExecutors.mainThread().execute(() -&gt; {
                if (musics.isEmpty()) {
                    callback.onDataNotAvailable();
                } else {
                    callback.onDataLoaded(musics);
                }
            });
          };
  
          appExecutors.diskIO().execute(runnable);
      }
  
      @Override
      public void findById(@NonNull String dataId, @NonNull GetDataCallback&lt;Music&gt; callback) {
          Runnable runnable = () -&gt; {
              final Music music = musicDao.findMusicById(dataId);
  
              appExecutors.mainThread().execute(() -&gt; {
                  if(music != null) {
                      callback.onDataLoaded(music);
                  } else {
                      callback.onDataNotAvailable();
                  }
              });
          };
  
          appExecutors.diskIO().execute(runnable);
      }
  
      @Override
      public void save(@NonNull Music data) {
  
      }
  
      @Override
      public void update(@NonNull Music data) {
  
      }
  
      @Override
      public void delete(@NonNull Music data) {
  
      }
  
      @Override
      public void delete(@NonNull String dataId) {
  
      }
  
      @Override
      public void deleteAll() {
  
      }
  
      @VisibleForTesting
      static void clearInstance() {
          INSTANCE = null;
      }
  </code></pre>
  
  <p>trace:</p>
  
  <blockquote>
  <pre><code>   java.lang.NoSuchMethodError: No static method clearInstance()V in class
  </code></pre>
    
    <p>Lcom/stapeapp/stape/music/domain/datasource/MusicLocalDataSource; or
    its super classes (declaration of
    'com.stapeapp.stape.music.domain.datasource.MusicLocalDataSource'
    appears in /data/app/com.stapeapp.stape.mock-2/base.apk)
                at com.stapeapp.stape.music.domain.datasource.MusicLocalDataSourceTest.cleanUp(MusicLocalDataSourceTest.java:56)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
                at android.support.test.internal.runner.junit4.statement.RunAfters.evaluate(RunAfters.java:80)
                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                at org.junit.runners.Suite.runChild(Suite.java:128)
                at org.junit.runners.Suite.runChild(Suite.java:27)
                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
                at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
                at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
                at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
                at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1871)</p>
  </blockquote>
  
  <p>someone knows what's happening and/or can give me some directions?</p>
  
  <p><strong>Edit:</strong>
  this error occurred again when I created a new instance of a entity in other test, this entity is static attribute in the test.</p>
  
  <pre><code>public class IEMusicDaoTest {
      private static final Music MUSIC = new Music("1", "title", "artistic"); // error occurred here
      private StapeDatabase mDatabase;
  
      @Before
      public void setUp() throws Exception {
          Context context = InstrumentationRegistry.getContext();
          mDatabase = Room.inMemoryDatabaseBuilder(context, StapeDatabase.class).build();
      }
  
      @After
      public void tearDown() throws Exception {
          mDatabase.close();
      }
  
      @Test
      public void should_have_success_in_save_music() {
          mDatabase.musicDao().save(MUSIC);
  
          Music loaded = mDatabase.musicDao().findMusicById(MUSIC.getId());
  
          assertMusic(loaded, MUSIC.getId(), MUSIC.getName(), MUSIC.getArtist());
  
      }
  
      private void assertMusic(Music loaded, String id, String name, String artist) {
          Assert.assertThat(loaded, CoreMatchers.notNullValue());
          Assert.assertThat(loaded.getId(), CoreMatchers.is(id));
          Assert.assertThat(loaded.getName(), CoreMatchers.is(name));
          Assert.assertThat(loaded.getArtist(), CoreMatchers.is(artist));
      }
  </code></pre>