title: Google Espresso java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN
body: <p>I am new to Espresso UI testing. </p>
  
  <p>I am getting this error while running tests (ADT Eclipse IDE ).</p>
  
  <p>The app is already developed and there are lots of request going on while launching the app. it is not possible to rewrite the app. but i need to find the way to test this UI even if there is any delay in the loading of the components.</p>
  
  <pre><code>        java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.xx.android/com.yy.core.android.map.MapActivity } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1390913271702 and and now the last time the queue went idle was: 1390913271767. If these numbers are the same your activity might be hogging the event queue.
          at com.google.android.apps.common.testing.testrunner.GoogleInstrumentation.startActivitySync(GoogleInstrumentation.java:277)
          at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119)
          at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:97)
          at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:104)
          at com.gulesider.android.test.UItest.setUp(UItest.java:25)
          at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
          at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
          at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
          at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:167)
          at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1799)
  </code></pre>
  
  <ol>
  <li>I have one library project called “Core” - it will not generate any .apk</li>
  <li>Also i have one Android project called “AA” which will access “Core”.  - This is AA.apk</li>
  <li>Now i have created a test project called “UItest” </li>
  </ol>
  
  <p>Manifest:        </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.AA.android.test"
          android:versionCode="1"
          android:versionName="1.0" &gt;
      &lt;uses-sdk android:minSdkVersion="8" 
              android:targetSdkVersion="18" /&gt;
      &lt;instrumentation
        android:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
        android:targetPackage="com.AA.android"/&gt;
      &lt;application
              android:allowBackup="true"
              android:icon="@drawable/ic_launcher"
              android:label="@string/app_name" &gt;
      &lt;activity
                  android:name="com.core.android.map.MapActivity"
                  android:label="@string/app_name" &gt;
                  &lt;intent-filter&gt;
                      &lt;action android:name="android.intent.action.MAIN" /&gt;
                      &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
                  &lt;/intent-filter&gt;
              &lt;/activity&gt;
              &lt;uses-library android:name="android.test.runner" /&gt;
          &lt;/application&gt;
      &lt;/manifest&gt;
  </code></pre>
  
  <p>My test:        </p>
  
  <pre><code>    public class UItest extends ActivityInstrumentationTestCase2&lt;MapActivity&gt; {
          public UItest() {
              super(MapActivity.class);
          }
  
          @Override
          public void setUp() throws Exception {
              super.setUp();
  
              getActivity();
  
          }
  
          public void testSearchBox() {
  
              Espresso.onView(ViewMatchers.withId(R.id.menu_button_logo)).perform(ViewActions.click());
  
          }
  
      }
  </code></pre>