testing-samples icon indicating copy to clipboard operation
testing-samples copied to clipboard

Could not launch intent Intent

Open charbgr opened this issue 11 years ago • 4 comments

If i include in build.gradle

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
        exclude module: 'recyclerview-v7'
    }

espresso gives me this error

java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.example.android.testing.espresso.BasicSample/.MainActivity } 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 1442838884986 and now the last time the queue went idle was: 1442838884986. If these numbers are the same your activity might be hogging the event queue.
at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:353)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:219)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:255)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
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:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)

Why is this happening?

charbgr avatar Sep 21 '15 12:09 charbgr

Looks like the Activity cannot be launched and the runner is timing out. Can you actually see the Activity start on the device? Does the Activity launch if you start it manually? Which emulator and/or device have you been using? Does this happen only on a specific device. It also looks like you made some changes to the sample itself do you mind posting your build.gradle file?

slinzner-corp avatar Sep 23 '15 19:09 slinzner-corp

if i exclude appcompat and support-v4 works fine

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2'){
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
}

charbgr avatar Sep 23 '15 19:09 charbgr

Great thanks, a lot of developers see similar issue recently. There is a tools bug for it: https://code.google.com/p/android/issues/detail?id=192497 and i also posted a solution to our testing codelab: https://github.com/googlecodelabs/android-testing/blob/master/app/build.gradle#L96

slinzner-corp avatar Nov 03 '15 16:11 slinzner-corp

having the same issue.. As you can see the numbers are same 1589092127478

   For your reference the last time the event queue was idle before your activity launch request was 
   1589092127478 and now the last time the queue went idle was: 1589092127478. If these numbers 
   are the same your activity might be hogging the event queue.

But the issue persists only in some devices(Worked on Android API level 21 but not on API 10).

febinmathew avatar May 10 '20 07:05 febinmathew