question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Activity net.openid.appauthdemo.MainActivity has leaked ServiceConnection

See original GitHub issue

I’ve encountered a leak problem. I was using a simulator without Chrome installed. On a Chrome installed simulator the leak won’t happen.

This leak was occurred when I hit the back button and while the MainActivity turned into background.

And when I dig a little deeper into the problem I found that the mBrowserPackage in the BrowserHandler was resolved to com.android.browser and the return value of CustomTabsClient#bindCustomTabsService(...) is false. So the connection is not retained in the BrowserHandler and when BrowserHandler#unbind() is called, nothing is unbind.

I’ve tried to retained the connection even when CustomTabsClient#bindCustomTabsService(...) returns false. It seems solve the leak problem, but I’m not sure will there be any side effects.

07-06 10:12:45.442 3929-3929/net.openid.appauthdemo E/ActivityThread: Activity net.openid.appauthdemo.MainActivity has leaked ServiceConnection net.openid.appauth.BrowserHandler$1@2206f76 that was originally bound here
                                                                      android.app.ServiceConnectionLeaked: Activity net.openid.appauthdemo.MainActivity has leaked ServiceConnection net.openid.appauth.BrowserHandler$1@2206f76 that was originally bound here
                                                                          at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1092)
                                                                          at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:986)
                                                                          at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1303)
                                                                          at android.app.ContextImpl.bindService(ContextImpl.java:1286)
                                                                          at android.content.ContextWrapper.bindService(ContextWrapper.java:604)
                                                                          at android.support.customtabs.CustomTabsClient.bindCustomTabsService(CustomTabsClient.java:60)
                                                                          at net.openid.appauth.BrowserHandler.bindCustomTabsService(BrowserHandler.java:86)
                                                                          at net.openid.appauth.BrowserHandler.<init>(BrowserHandler.java:61)
                                                                          at net.openid.appauth.AuthorizationService.<init>(AuthorizationService.java:101)
                                                                          at net.openid.appauthdemo.MainActivity.onCreate(MainActivity.java:63)
                                                                          at android.app.Activity.performCreate(Activity.java:6237)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:7
  • Comments:34 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
ghostcommented, May 18, 2017

I am using 0.6.0 and this issue is reproducible.

6reactions
SWRHARDcommented, Jul 15, 2019

still not working, 0.7.1

still not fixed, will be fixed this? it’s important problem, cant understand why this is not fixed yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Activity has leaked ServiceConnection net.openid ...
Android Studio says the code causing this error is "authService.performTokenRequest()". I have looked around and some solved it by calling " ...
Read more >
Mainactivity Has Leaked Serviceconnection - ADocLib
I'm working on my first Android app. I've got three activities in my app and the user switches back and forth pretty frequently....
Read more >
Activitythread活动泄露了原本绑定在这里的serviceconnection, 已泄露 ...
Activity net.openid.appauthdemo.MainActivity has leaked , ... Activity activities.MainActivity has leaked ServiceConnection net.openid.appauth.browser.
Read more >
"Activity ... has leaked ServiceConnection" exception on android
If I set my applicationId in gradle to something that does not start with com.clover I get "Activity has leaked ServiceConnection" when I ......
Read more >
Android MainActivity has leaked ServiceConnection
Everything is working fine, except when changing orientation I get a service connection leak error when the activity is recreated. I am using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found