4

Not able to run instrumentation test with android orchestrator, I have followed developer doc and made same changes but it's not working.

Screen shot and logs are attached. Any help would be appreciated thanks in advance

In the console it is showing No test were found

Logcat:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.ctpl.myinstrumentationtest, PID: 6608 java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com.example.ctpl.myinstrumentationtest.test/android.support.test.runner.AndroidJUnitRunner}: java.lang.RuntimeException: Cannot connect to android.support.test.orchestrator.OrchestratorService at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5868) at android.app.ActivityThread.access$1100(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.RuntimeException: Cannot connect to android.support.test.orchestrator.OrchestratorService at android.support.test.orchestrator.instrumentationlistener.OrchestratedInstrumentationListener.connect(OrchestratedInstrumentationListener.java:87) at android.support.test.runner.AndroidJUnitRunner.onCreate(AndroidJUnitRunner.java:303) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5863) at android.app.ActivityThread.access$1100(ActivityThread.java:199)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

  1. List item

Jeeva
  • 641
  • 1
  • 6
  • 7

1 Answers1

2

I had the same problem but with androidx orchestrator. I was getting the same exception but the package was different:
Caused by: java.lang.RuntimeException: Cannot connect to androidx.test.orchestrator.OrchestratorService.

I have found the description of possbile root cause in this github thread. There's an iteresting discussion, but it seems that there's no general solution for this yet.

For me the problem was caused by setting the target sdk to 30 and launching the app on an android 30 emulator. So launching tests on emulator with api < 30 resolved this.

Daniil
  • 1,290
  • 11
  • 17
  • Problem persists today, but only if you install test-orchestrator and test-services manually from command line for some reason. If you do everthing from android studio it works with v1.4.0 of test-orchestrator on Android 11 also. – Nilzor Jan 12 '22 at 12:11
  • 2
    Solved: If you're getting this when running from command line, follow the instructions in this answer (only relevant for Android 11 and up): https://stackoverflow.com/a/67466181/507339 – Nilzor Jan 12 '22 at 13:25
  • Nilzor, You life saver !!!!! – NikofTime Feb 11 '22 at 20:29