Group Group Group Group Group Group Group Group Group

Chapter 27: leaked ServiceConnection

Hi,

First of all, thank you very much for this book. I have learnt a lot from it. I am at chapter 27 Episode Player and when I build and run the app I get the following error and app crashes:

2020-01-16 08:58:48.810 30808-30808/raywenderlich.com.podplay E/ActivityThread: Activity raywenderlich.com.podplay.ui.PodcastActivity has leaked ServiceConnection android.media.browse.MediaBrowser$MediaServiceConnection@20b76c9 that was originally bound here
android.app.ServiceConnectionLeaked: Activity raywenderlich.com.podplay.ui.PodcastActivity has leaked ServiceConnection android.media.browse.MediaBrowser$MediaServiceConnection@20b76c9 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:1540)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1432)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1615)
at android.app.ContextImpl.bindService(ContextImpl.java:1567)
at android.content.ContextWrapper.bindService(ContextWrapper.java:694)
at android.media.browse.MediaBrowser$1.run(MediaBrowser.java:187)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

Could you please help me fix this issue?

Thanks
Anshul

@tblank Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi Ashnul,

Thank you for reading the Android Apprentice, and I’m glad you are enjoying it so far!

I’m sorry to see that you are having an issue in Chapter 27. If you will please answer the following questions, I can help track down the possible cause for your issue.

  1. Does the same error occur if you run the final project from the downloadable book source code? If the error doesn’t occur, then I would try to do a comparison of your own project to the published final project code and see if you can spot any differences.

  2. If you are getting the error using the published final project, then please let me know what version of Android you are running on your emulator or device.

Thank you,
Tom