title: Can't launch activity only once - Did you forget to launch the activity by calling getActivity() or startActivitySync or similar?
body: <p>I need to launch activity <strong>only once</strong> before all tests.
  So I use annotation <code>@BeforeClass</code>  for this.</p>
  
  <p>Here Espresso's test:</p>
  
  <pre><code>@RunWith(AndroidJUnit4::class)
  class JsonViewActivityTest {
  
      companion object {
          init {
              // things that may need to be setup before companion class member variables are instantiated
          }
  
          @get:Rule
  var jsonViewIntentsTestRule = IntentsTestRule(JsonViewActivity::class.java, false, false)
  
          private val instrumentation = InstrumentationRegistry.getInstrumentation()
          private val context = instrumentation.getContext()
          private val targetContext = instrumentation.getTargetContext()
          private val intent = Intent(targetContext, JsonViewActivity::class.java)
  
          @BeforeClass
          @JvmStatic
          fun beforAll() {
              Intent(targetContext, JsonViewActivity::class.java)
              val bundle = Bundle()
              val inputStream = context.assets.open(StubUtil.TradersStub.ONE_TRADER_HAS_WALLETS.stubName)
              val content = inputStream.readBytes().toString(StandardCharsets.UTF_8)
              val jsonArray = GsonUtil.gson.fromJson(content, JsonArray::class.java)
              val jsonTrader = jsonArray.get(0)
              val trader = GsonUtil.gson.fromJson(jsonTrader, Trader::class.java)
              val wallet = trader.wallets[0]
              bundle.putString(JsonViewActivity.WALLET_JSON, GsonUtil.gson.toJson(wallet))
              intent.putExtras(bundle)
  
              jsonViewIntentsTestRule.launchActivity(intent)
          }
  
          @AfterClass
          @JvmStatic
          fun afterAll() {
              jsonViewIntentsTestRule.finishActivity()
          }
      }
  
      @Test
      fun toolBar_height() {
          onView(withId(R.id.toolBar))
                  .check(ViewAssertions.matches(CustomMatchers.withHeightResId(R.dimen.tool_bar_height)))
      }
  }
  </code></pre>
  
  <p>But test <code>toolBar_height</code> is fail with message:</p>
  
  <pre><code>Client not ready yet..
  Started running tests
  
  java.lang.RuntimeException: No activities found. Did you forget to launch the activity by calling getActivity() or startActivitySync or similar?
  at androidx.test.espresso.base.RootViewPicker.waitForAtLeastOneActivityToBeResumed(RootViewPicker.java:169)
  at androidx.test.espresso.base.RootViewPicker.get(RootViewPicker.java:83)
  at androidx.test.espresso.ViewInteractionModule.provideRootView(ViewInteractionModule.java:77)
  at androidx.test.espresso.ViewInteractionModule_ProvideRootViewFactory.provideRootView(ViewInteractionModule_ProvideRootViewFactory.java:35)
  at androidx.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:24)
  at androidx.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:10)
  at androidx.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:62)
  at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:276)
  at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:268)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at android.os.Handler.handleCallback(Handler.java:739)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:5417)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>