title: JUnit Android studio initialization Error
body: <p>I am fairly new to Android Studio. Excuse me if the solution is really easy; I am getting initialization error when I am trying to run my JUnit test.</p>
  
  <p>Here's my JUnit test:</p>
  
  <pre><code>package mu.organyze;
  
  import android.app.Activity;
  import android.support.test.runner.AndroidJUnit4;
  import android.support.test.rule.ActivityTestRule;
  import android.widget.TextView;
  
  
  import org.junit.Rule;
  import org.junit.Test;
  import org.junit.Before;
  import org.junit.runner.RunWith;
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertNotNull;
  import static org.junit.Assert.assertNull;
  import static org.junit.Assert.assertTrue;
  import android.widget.Button;
  import static org.mockito.Mockito.*;
  
  
  //mock creation
  @RunWith(AndroidJUnit4.class)
  public class UnitTestForHomeScreen {
  //
      @Rule
      public ActivityTestRule&lt;HomeScreen&gt; mActivityRule = new ActivityTestRule(HomeScreen.class);
  
      @Test
      public void checkLogOutButton() throws Exception {
          Button buttonLogOut = mock(Button.class);
          when(buttonLogOut.getId()).thenReturn(R.id.buttonLogOut);
  
          HomeScreen activity = mActivityRule.getActivity();
          activity.onClick(buttonLogOut);
          //assert continas after LogOut button is push
      }
      @Test
      public void checkStoreButton() throws Exception {
          Button storeButton = mock(Button.class);
          when(storeButton.getId()).thenReturn(R.id.buttonStoreData);
  
          HomeScreen activity = mActivityRule.getActivity();
          activity.onClick(storeButton);
          //assert continas after storeButton is push
      }
  
      @Test
      public void checkSearchButton() throws Exception {
          Button searchButton = mock(Button.class);
          when(searchButton.getId()).thenReturn(R.id.buttonSearch);
  
          HomeScreen activity = mActivityRule.getActivity();
          activity.onClick(searchButton);
          //assert contains after searchButton button is push
      }
  
      @Test
      public void checkRankingButton() throws Exception {
          Button rankingButton = mock(Button.class);
          when(rankingButton.getId()).thenReturn(R.id.buttonRankings);
  
          HomeScreen activity = mActivityRule.getActivity();
          activity.onClick(rankingButton);
          //assert contains after LogOut button is push
      }
  
      @Test
      public void check() throws Exception {
          Button storeButton = mock(Button.class);
          when(storeButton.getId()).thenReturn(R.id.buttonStoreData);
  
          HomeScreen activity = mActivityRule.getActivity();
          activity.onClick(storeButton);
          //assert contains after LogOut button is push
      }
  
      //    public void checkInputs() throws Exception {
  //        Activity activity =  mActivityRule.getActivity();
  //        assertNotNull(activity.findViewById(R.id.textHomeMessage));
  //        TextView textHomeMessage = (TextView) activity.findViewById(R.id.textHomeMessage);
  //        assertTrue(textHomeMessage.isShown());
  //        assertEquals("What do you want to do?", textHomeMessage.getText());
  //        assertNull(activity.findViewById(R.id.buttonStoreData));
  
  
          //        StoreData itemAdding = new StoreData();
  //        itemAdding.editTextCount.setText("2");
  //        assertArrayEquals(itemAdding.getCountItem(),"2");
   //   }
  }
  </code></pre>
  
  <p>And here's my build.gradle file.</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 26
      buildToolsVersion '26.0.2'
      defaultConfig {
          applicationId "mu.organyze"
          minSdkVersion 24
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
  
      compile 'com.android.support:appcompat-v7:26.+'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      compile 'com.google.firebase:firebase-auth:10.0.1'
      compile 'com.google.firebase:firebase-database:10.0.1'
      testCompile 'junit:junit:4.12'
      testCompile 'com.android.support:support-annotations:23.4.0'
      testCompile 'com.android.support.test:runner:0.4.1'
      testCompile 'com.android.support.test:rules:0.4.1'
      testCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
      testCompile 'com.google.dexmaker:dexmaker:1.2'
      testCompile "org.mockito:mockito-core:2.12.0"
      testCompile 'org.mockito:mockito-android:2.12.0'
      androidTestUtil 'com.android.support.test:orchestrator:1.0.1'
      androidTestCompile 'org.hamcrest:hamcrest-integration:1.3'
  }
  
  
  
  
  
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p>I've tried solutions followed by other people such as:
  Change my run config, changed imports in my JUnit file.</p>
  
  <p>Error message:</p>
  
  <pre><code>java.lang.Exception: Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)
  
      at org.junit.runners.model.InitializationError.&lt;init&gt;(InitializationError.java:38)
      at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:111)
      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
  </code></pre>