android-test icon indicating copy to clipboard operation
android-test copied to clipboard

Ran ui/BasicSample fail on Android 9 HUAWEI

Open YuriZheng opened this issue 4 years ago • 6 comments
trafficstars

I can't run tests in project ui/BasicSample on device with Android 9 works on device with Android10 I run unittest on android 9 and fail:

java.lang.AssertionError: Activity never becomes requested state "[CREATED, DESTROYED, RESUMED, STARTED]" (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)
at androidx.test.ext.junit.rules.ActivityScenarioRule.lambda$new$0$ActivityScenarioRule(ActivityScenarioRule.java:70)
at androidx.test.ext.junit.rules.ActivityScenarioRule$$Lambda$0.get(Unknown Source:2)
at androidx.test.ext.junit.rules.ActivityScenarioRule.before(ActivityScenarioRule.java:103)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
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 androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:154)
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 androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:395)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2154)

I ran the tests on an Android 9 HUAWEI and they all fail I clone ui/BasicSample project and ran unit test, I did not modify the code this is my phone info: HUAWEI COR-AL00 version:Android 9 emui: 9.1.0

Or more info you wanted and tell me,I really don't know what to do, it took me a lot of time

Thanks.

YuriZheng avatar Jan 14 '21 01:01 YuriZheng

Can you get a copy of the logcat and attach it here? From command line, adb logcat -d > logcat.txt should work.

brettchabot avatar Jan 14 '21 20:01 brettchabot

This is ran screenshot: Screenshot from 2021-01-15 14-27-16 Screenshot from 2021-01-15 14-29-20

This is the logcat:

logcat.txt

Thanks

YuriZheng avatar Jan 15 '21 06:01 YuriZheng

I don't see anything obviously wrong in the logcat. Sorry without having access to the device this is going to be difficult to troubleshoot. Do the tests work if you run them on an Android 9 AVD?

I'd also suggest to check the device settings https://developer.android.com/training/testing/espresso/setup

brettchabot avatar Jan 19 '21 17:01 brettchabot

Ran on emulator pixel_2_api_28 android success Ran on HUAWEI COR-AL00 android 9 fail

I don't know what to do!

I already closed the animation and trun on the 'Auto-launch' on optimizer, but it doesn't work

Is there any other way?

YuriZheng avatar Jan 20 '21 07:01 YuriZheng

I'm running out of suggestions sorry. You could try running through a debugger and seeing if the callbacks on MainActivity are occurring

brettchabot avatar Jan 20 '21 16:01 brettchabot

I have the same problem, I try to run the test on Xiomi Redmi 5 plus with Android 8.1, it fails.

The solution I found was to allow "Display pop-up windows while running in the background" under "Other permissions" in the app info.

marvinjgh avatar Nov 11 '21 00:11 marvinjgh