Baseflow / Baseflow/flutter-geolocator

[Android] MainActivity has leaked IntentReceiver

Open
#915 2 comments 0 reactions 0 assignees View on GitHub
P2 platform: android type: bug
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

## 🐛 Bug Report

It reports MainActivity has leaked IntentReceiver `com.baseflow.geolocator.location.LocationServiceStatusReceiver`, when exiting the app.

### Expected behavior

Call `unregisterReceiver()` when exiting the app.

### Reproduction steps

1. Checkout the example project
2. Build the example project
3. Run the example app
4. Give location permission by tapping the button
5. Exit the app

Error log in the console:

```
E/ActivityThread(17969): Activity com.baseflow.geolocator_example.MainActivity has leaked IntentReceiver com.baseflow.geolocator.location.LocationServiceStatusReceiver@10738ec that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(17969): android.app.IntentReceiverLeaked: Activity com.baseflow.geolocator_example.MainActivity has leaked IntentReceiver com.baseflow.geolocator.location.LocationServiceStatusReceiver@10738ec that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(17969): at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:1717)
E/ActivityThread(17969): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1494)
E/ActivityThread(17969): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1757)
E/ActivityThread(17969): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1723)
E/ActivityThread(17969): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1711)
E/ActivityThread(17969): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:724)
E/ActivityThread(17969): at com.baseflow.geolocator.LocationServiceHandlerImpl.onListen(LocationServiceHandlerImpl.java:57)
E/ActivityThread(17969): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:218)
E/ActivityThread(17969): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:197)
E/ActivityThread(17969): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/ActivityThread(17969): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/ActivityThread(17969): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD1MYkhaLxyPjtoFDxe45u43DI.run(Unknown Source:12)
E/ActivityThread(17969): at android.os.Handler.handleCallback(Handler.java:938)
E/ActivityThread(17969): at android.os.Handler.dispatchMessage(Handler.java:99)
E/ActivityThread(17969): at android.os.Looper.loopOnce(Looper.java:201)
E/ActivityThread(17969): at android.os.Looper.loop(Looper.java:288)
E/ActivityThread(17969): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/ActivityThread(17969): at java.lang.reflect.Method.invoke(Native Method)
E/ActivityThread(17969): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/ActivityThread(17969): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Application finished.

```

### Configuration

**Version:** 8.0.0

**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the leak in the example project after granting location permission and exiting the app. Trace the registration reported at LocationServiceHandlerImpl.java:57 and verify that the LocationServiceStatusReceiver is unregistered when the event stream or activity ends; done means the console no longer reports IntentReceiverLeaked.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, flutter, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.