Exception when running instrumented tests with Hilt and App Startup - android

I am starting to setup some instrumented tests on my project, but when I run them, I get the following exception on logcat:
2022-04-11 10:41:09.352 24409-24409/com.example.appstartupinstrumentationtest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.appstartupinstrumentationtest, PID: 24409
java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
at android.app.ActivityThread.installProvider(ActivityThread.java:8195)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7726)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7546)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: androidx.startup.StartupException: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:162)
at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:198)
at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:38)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2429)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2399)
at android.app.ActivityThread.installProvider(ActivityThread.java:8190)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7726) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7546) 
at android.app.ActivityThread.access$1500(ActivityThread.java:301) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:246) 
at android.app.ActivityThread.main(ActivityThread.java:8633) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) 
Caused by: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)
at dagger.hilt.android.internal.testing.TestApplicationComponentManager.generatedComponent(TestApplicationComponentManager.java:96)
at dagger.hilt.android.testing.HiltTestApplication.generatedComponent(HiltTestApplication.java:49)
at dagger.hilt.EntryPoints.get(EntryPoints.java:59)
at dagger.hilt.android.EntryPointAccessors.fromApplication(EntryPointAccessors.kt:35)
at com.example.appstartupinstrumentationtest.InitializerEntryPoint$Companion.resolve(InitializerEntryPoint.kt:20)
at com.example.appstartupinstrumentationtest.SomeComponentInitializer.create(SomeComponentInitializer.kt:10)
at com.example.appstartupinstrumentationtest.SomeComponentInitializer.create(SomeComponentInitializer.kt:7)
at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:155)
at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:198) 
at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:38) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:2429) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:2399) 
at android.app.ActivityThread.installProvider(ActivityThread.java:8190) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7726) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7546) 
at android.app.ActivityThread.access$1500(ActivityThread.java:301) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:246) 
at android.app.ActivityThread.main(ActivityThread.java:8633) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
My real codebase is much more complex, but I created a much simpler project where I am able to reproduce the issue HERE.
From what I understood, when running the instrumentation tests, the startup code is first executed, even before anything on the test class (before #Before and #BeforeClass methods).
What is the best way to handle this?

Related

upi payment getting error in razorpay android integration

I am working on the android studio when I am trying payment gateway integration using Razorpay. when I am using the card payment method it is working fine but whenever using the UPI payment method it gives the following error.
com.example.navdrawerdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.navdrawerdemo, PID: 31569
java.lang.RuntimeException: Unable to destroy activity {com.example.navdrawerdemo/com.razorpay.CheckoutActivity}: java.lang.IllegalArgumentException: Receiver not registered: null
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5112)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5141)
at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2067)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7697)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
Caused by: java.lang.IllegalArgumentException: Receiver not registered: null
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1459)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1642)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:715)
at com.razorpay.CheckoutPresenterImpl.cleanUpOnDestroy(CheckoutPresenterImpl.java:705)
at com.razorpay.PluginOtpElfCheckoutPresenterImpl.cleanUpOnDestroy(PluginOtpElfCheckoutPresenterImpl.java:17)
at com.razorpay.a_$P$.onDestroy(BaseCheckoutActivity.java:178)
at android.app.Activity.performDestroy(Activity.java:8245)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1345)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5097)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5141) 
at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44) 
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2067) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7697) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952) 

React Native app crashing at startup on Android: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl"

I am using React Native v 0.62.2 and I am trying to get my project running on Android as well. Up until now, I had focussed development on iOS and therefore did never run the Android app. Now I wanted to run the android app but the app crashes on startup right after the splash screen was shown with the following stacktrace:
java.lang.RuntimeException: Unable to create application com.myapp.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6612)
at android.app.ActivityThread.access$1300(ActivityThread.java:233)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at com.facebook.react.devsupport.a.a(:90)
at com.facebook.react.q.<init>(:238)
at com.facebook.react.r.b(:281)
at com.facebook.react.t.a(:87)
at com.facebook.react.t.h(:39)
at com.myapp.MainApplication.onCreate(:48)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607)
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
Caused by: java.lang.ClassNotFoundException: com.facebook.react.devsupport.DevSupportManagerImpl
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.facebook.react.devsupport.a.a(:68)
at com.facebook.react.q.<init>(:238) 
at com.facebook.react.r.b(:281) 
at com.facebook.react.t.a(:87) 
at com.facebook.react.t.h(:39) 
at com.myapp.MainApplication.onCreate(:48) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607) 
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl" on path: DexPathList[[zip file "/data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/base.apk"],nativeLibraryDirectories=[/data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/lib/x86, /data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/base.apk!/lib/x86, /system/lib, /system_ext/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:454) 
at java.lang.Class.forName(Class.java:379) 
at com.facebook.react.devsupport.a.a(:68) 
at com.facebook.react.q.<init>(:238) 
at com.facebook.react.r.b(:281) 
at com.facebook.react.t.a(:87) 
at com.facebook.react.t.h(:39) 
at com.myapp.MainApplication.onCreate(:48) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607) 
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
I searched the web for solutions or at least hints but did unfortunately not find any solution or even any idea of what could be done to fix this issue.
Does anyone have any idea? Also please let me know if you need any further information in order to be able to answer the question.
Thanks a lot!
For all who are struggling with this issue as well - after a long period of research plus try and error, I got it finally fixed.
It seems that this issue actually is correlated to OK HTTP. The steps that made me get it running were the following:
Enable MultiDex but also keep attention on going for the AndroidX solution (as I use the latest version of React Native which already leverages AndroidX) as stated in the following answer:
https://stackoverflow.com/a/56875424/9055450
Follow the instructions given in the following comment adding ProGuard files: https://github.com/facebook/react-native/issues/9043#issuecomment-298832659

RxAndroid crashes when AndroidScheduler.mainThread() used

I have used RxJava and RxAndroid to fetch data from api and update my view. But after using RxAndroid AndroidScheduler.mainThread() the app crashes with unknown exceptions.
Also I am using RxJava & RxAndroid version 3.0.0 as recommended by RX
Exception:
2020-08-04 22:15:24.879 6831-6831/com.saswata.illeo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.saswata.illeo, PID: 6831
java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
at io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.<clinit>(AndroidSchedulers.java:33)
at io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.mainThread(AndroidSchedulers.java:44)
at com.saswata.illeo.view.activity.ListActivity.fetchData(ListActivity.kt:33)
at com.saswata.illeo.view.activity.ListActivity.onCreate(ListActivity.kt:26)
at android.app.Activity.performCreate(Activity.java:7032)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1236)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2814)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2943)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1630)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6626)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: IL.
at io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.<clinit>(AndroidSchedulers.java:33) 
at io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.mainThread(AndroidSchedulers.java:44) 
at com.saswata.illeo.view.activity.ListActivity.fetchData(ListActivity.kt:33) 
at com.saswata.illeo.view.activity.ListActivity.onCreate(ListActivity.kt:26) 
at android.app.Activity.performCreate(Activity.java:7032) 
at android.app.Activity.performCreate(Activity.java:7023) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1236) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2814) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2943) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1630) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6626) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811) 
Code:
onserverInst.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({//someWork},{//someError})
I just figured out that we can do the same by:
onserverInst
.subscribeOn(Schedulers.io())
.subscribe({
runOnUiThread{
// UI work
}
//someWork
},{//someError})
without using RxAndroid as I think it's pretty useless now. (Atleast now)

Ionic Capacitor firebase push notification, error:Default FirebaseApp is not initialized in this process

I am new to Capacitor and have migrating my Cordova project to Capacitor.
I trying to get my notification messages working. Therefore i followed the steps shown in
https://capacitor.ionicframework.com/docs/guides/push-notifications-firebase/
Once i build my project, i am opening the project and Android Studio starts. I preform a run, and the app the starts to get downloaded on to my phone, which i then run.
And i get this error message shown below when it comes registering my phone for notification messages.
Am i missing a step?
The google-services.json is also placed in Andriod-->App
Thanks
E/Capacitor: Serious error executing plugin
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$1.run(Bridge.java:515)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.aardra.cloud. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##19.3.0:184)
at com.google.firebase.messaging.FirebaseMessaging.getInstance(com.google.firebase:firebase-messaging##20.1.2:1)
at com.getcapacitor.plugin.PushNotifications.register(PushNotifications.java:82)
at java.lang.reflect.Method.invoke(Native Method) 
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) 
at com.getcapacitor.Bridge$1.run(Bridge.java:515) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:201) 
at android.os.HandlerThread.run(HandlerThread.java:65) 
E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
Process: com.aardra.cloud, PID: 749
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.getcapacitor.Bridge$1.run(Bridge.java:524)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$1.run(Bridge.java:515)
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:201) 
at android.os.HandlerThread.run(HandlerThread.java:65) 
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.aardra.cloud. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##19.3.0:184)
at com.google.firebase.messaging.FirebaseMessaging.getInstance(com.google.firebase:firebase-messaging##20.1.2:1)
at com.getcapacitor.plugin.PushNotifications.register(PushNotifications.java:82)
at java.lang.reflect.Method.invoke(Native Method) 
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) 
at com.getcapacitor.Bridge$1.run(Bridge.java:515) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:201) 
at android.os.HandlerThread.run(HandlerThread.java:65) 
I had the same problem. In my case I forgot to put google-services.json in android/app folder.
Verify:
google-services.json be in android/app folder and your Android package name should match the appId from your capacitor.config.json file.
We used com.mydomain.myappname for this Capacitor app ID, so that is what we’ll use for this entry.
capacitor.config.json has PushNotifications setup:
{
...
"plugins": {
"SplashScreen": {
...
},
"PushNotifications": {
"presentationOptions": ["badge", "sound", "alert"]
}
},
...
}
Then build your js project and sync.
npx cap sync android
npx cap open android
And build your Android app or test in an emulator.

Cannot connect to android.support.test.orchestrator.OrchestratorService

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
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) 
List item
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.

Categories

Resources