2

I am an Android Developer and facing a very serious issue that isn't mentioned anywhere with solution.

I am trying to run Expresso automated tests on my oneplus6t. But every single time from a year I am unable to test.

The error message is something like this:

"Testing started at 09:46 AM ...
04/20 09:46:21: Launching 'ASyncSettingsTest' on OnePlus ONEPLUS A6010.
Running tests
$ adb shell am instrument -w -r -e debug false -e class 'com.declaree.declaree.ASyncSettingsTest' com.demo.test/androidx.test.runner.AndroidJUnitRunner
Timed out waiting for process (com.demo) to appear on oneplus-oneplus_a6010-21663687."

It's working in emulators and other manufacturing devices like pixel, moto, Samsung.

I do not find anything like this in the developer option too.

For tests to run, I have to open the application on my own then it runs.

FYI: Reboot, Reset, Wipe Cache doesn't work.

I am working in Android Studio 3.6.2

Does anybody have any solution? Thanks in advance.

Nensi Kasundra
  • 1,980
  • 6
  • 21
  • 34
Asif Ansari
  • 119
  • 12

1 Answers1

5

It is somehow related to oneplus specific restrictions of background work.

To get rid of this, go

Settings -> Battery -> Battery optimization -> Your app (not package.test but application) -> Don't optimize -> Done

Works on OnePlus 3t.

  • 1
    Works on oneplus 7t too, you save the day! – Jian Guo May 15 '20 at 09:01
  • OMG, you saved my months. Thank you very much. :-) 100 thanks to you. For the first time in 2 years, I am able to run UI test in my OnePlus Thanks a lot – Asif Ansari May 21 '20 at 05:53
  • @VladislavYundin , its now giving exception for clicking , works fine in emulator : androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 179, 2273 and precision: 16, 16' on view 'with id: com.test.test:id/btn_sync – Asif Ansari May 21 '20 at 08:44
  • Caused by: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission (not working even after giving this permission) – Asif Ansari May 21 '20 at 08:51
  • @AsifAnsari I've never faced this issue and I don't think it is related to OnePlus device. That may be opened keyboard or something else. Try checking [these](https://stackoverflow.com/questions/22163424/android-java-lang-securityexception-injecting-to-another-application-requires) solutions. – Vladislav Yundin May 22 '20 at 09:54
  • Oh, Saved lots of time Thanks @VladislavYundin – Vishal kumar singhvi Feb 22 '21 at 06:50