java.lang.IllegalArgumentException: Service not registered - Xamarin BoundServiceDemo crash

ZunZun USMember
edited May 2017 in Xamarin.Android

I had an issue with my existing Bound Service losing its Binder properties (The binder becomes disposed for some reason). So I went back a step and relearn the Bound Servcie. I downloaded the BoundServiceDemo application from Xamarin from the following page:
https://developer.xamarin.com/guides/android/application_fundamentals/services/part_2_-_bound_services/

The project built and run. But I noticed that if I do a sequence of Unbind from service and Bind to service(via button clicks in the project), the third stop will crash CONSISTENTLY. Pressing Get timestamp from service after binding to the service does not prevent the crash from happening. The stack trace is as follows:

05-23 10:33:21.334 11788 11788 D AndroidRuntime: Shutting down VM

05-23 10:33:21.344 11788 11788 E AndroidRuntime: FATAL EXCEPTION: main

05-23 10:33:21.344 11788 11788 E AndroidRuntime: Process:
com.xamarin.xample.boundservicedemo, PID: 11788

05-23 10:33:21.344 11788 11788 E AndroidRuntime:
java.lang.IllegalArgumentException: Service not registered:
[email protected]7c0e

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1156)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.app.ContextImpl.unbindService(ContextImpl.java:1452)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.content.ContextWrapper.unbindService(ContextWrapper.java:644)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
mono.android.view.View_OnClickListenerImplementor.n_onClick(Native
Method)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:30)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.view.View.performClick(View.java:5697)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.widget.TextView.performClick(TextView.java:10814)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.view.View$PerformClick.run(View.java:22526)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.os.Handler.handleCallback(Handler.java:739)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.os.Handler.dispatchMessage(Handler.java:95)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.os.Looper.loop(Looper.java:158)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
android.app.ActivityThread.main(ActivityThread.java:7229)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
java.lang.reflect.Method.invoke(Native Method)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)

05-23 10:33:21.344 11788 11788 E AndroidRuntime: at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

05-23 10:33:21.344 4699 4724 W VirtualScreenManagerService:
moveTaskBackToDisplayIfNeeded(): top activity or app is null

05-23 10:33:21.354 4699 4724 D InputDispatcher: Focused application
set to: xxxx

I am using VS2015 with Xamarin version 4.5.0.443. I hope this is not a bug with Xamarin because my application does multiple bind/unbind service during its lifetime. Can someone please shed some light? Thank you.

Sign In or Register to comment.