'Don't start Android UI test from Android Studio on real device

  1. UI Tests on Emulator - ok
  2. Debug on real device - ok
  3. UI Tests on real device - don't start with error:

java.lang.AssertionError: Activity never becomes requested state "[STARTED, CREATED, RESUMED, DESTROYED]" (last lifecycle transition = "PRE_ON_CREATE") at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338) at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:272) at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:195) .....

@LargeTest @RunWith(AndroidJUnit4ClassRunner::class) .....

ActivityScenario.launch(SplashActivity::class.java)



Solution 1:[1]

Allow the "display pop-up windows while running in the background permission" or something similar to that. It worked for me on a Redmi Note 8 device

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Omaka