java.lang.RuntimeException: Could not launch intent Intent only on emulator on api 28 (android 9)

0

Seeing this exception for an espresso test:

java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=/.root.presentationcomponent.implementation.RootActivity } within 45000 milliseconds. 
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 1603447989081 and now the last time the queue went idle was: 1603447994446. If these numbers are the same your activity might be hogging the event queue.
at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:490)
at androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:358)

Running this test on emulators with apis 23, 25, 27, 28 and this only fails 100% on api 28. Paged through all the other stackoverflows with this exception and most say the solution is disabling animations which is already done.

Test:

    @Test
    fun test() {
        masterRobot.apply {
          // conditions set here
        }

        // When app is launched
        activityRule.launchActivity(null)

        // When clicked retry
        onView(ViewMatchers.withId())
            .perform(ScrollToAction())
            .perform(click())

        // When the user clicks positive
        onView(ViewMatchers.withId())
            .perform(ScrollToAction())
            .perform(ViewActions.click())

        // Then, dialog
        Espresso.onView(ViewMatchers.withText())
            .inRoot(RootMatchers.isDialog())
            .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

        // When, set succeed, click OK and then click done.
        Espresso.onView(ViewMatchers.withText(R.string.DialogOk))
            .perform(ViewActions.click())

        addActivityResultVerifier(true)

        Espresso.onView(ViewMatchers.withId())
            .perform(ViewActions.click())

        // Then, app quits with successful activity result
        Espresso.onIdle()
        assertTrue(activityRule.activity.isFinishing || activityRule.activity.isDestroyed)

        // When app is finished and launched again
        activityRule.finishActivity()
        activityRule.launchActivity(null)

        // success text
        Espresso.onView(ViewMatchers.withId())
            .check(ViewAssertions.matches(ViewMatchers.withText()))
    }

Anyone have any other suggestions about why this might be happening? We do this behavior in a different test on a different page and have no issues.

android
kotlin
android-espresso
asked on Stack Overflow Oct 23, 2020 by Grace Michnovicz • edited Oct 24, 2020 by MaxV

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0