Crash when starting services in background
See original GitHub issueUsing a Pixel on Oreo (release not beta), I put my app in the background. A minute or two later, it crashed. LeakCanary 1.5.1
09-07 19:18:24.049 31787-31804/com.myapp:leakcanary E/AndroidRuntime: FATAL EXCEPTION: IntentService[HeapAnalyzerService]
Process: com.myapp:leakcanary, PID: 31787
java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.myapp/com.squareup.leakcanary.DisplayLeakService (has extras) }: app is in background uid UidRecord{74385af u0a385 CEM bg:+3m4s764ms idle procs:2 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505)
at android.app.ContextImpl.startService(ContextImpl.java:1461)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at com.squareup.leakcanary.AbstractAnalysisResultService.sendResultToListener(AbstractAnalysisResultService.java:38)
at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:59)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:35
- Comments:29 (21 by maintainers)
Top Results From Across the Web
android - Background Service is crashing on "start service"
The code working fine and it's displaying correct locations but when I click "Start Service" It crashes. I can't find the mistake: GPS ......
Read more >Screen goes black all background apps crash then screen ...
1. Open the run box by pressing the Windows Key + R and type msconfig · 2. System Configuration Utility box will open...
Read more >The reasons for the crash of the process in the background.
Many devices don't allow apps to run in the background for too long. Even with a foreground service. Keep the MyLocation app running...
Read more >CrashPlan app does not run (CrashPlan for Small Business)
CrashPlan app does not run (CrashPlan for Small Business) ... Opens, but displays the message: Cannot connect to background service.
Read more >Solved: Windows 10 Crashes on Startup
Part 2. How to Fix Windows 10 Crashed on Startup? · Method 1. Cleaning Dust · Method 2. Stop Fast Startup · Method...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, that’s because you can’t start services in the background anymore on API 26.
@JakeWharton @jrodbx You’ll have to use
ContextCompat.startForegroundService(...)
and post a notification while processing the leak. I think that’s actually better UX anyway because I’m always like “Is LeakCanary doing anything? Why is it taking so long?” If you guys could have a progress bar showing the analysis progress, that would be really cool.there is pull a request since December, could you please just merge it.