Baseflow / Baseflow/flutter-geolocator

[Bug]: Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter.baseflow.com/geolocator_updates_android.

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

Description

### Please check the following before submitting a new issue.

- [ ] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.

### Please select affected platform(s)

- [X] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows

### Steps to reproduce

I want location updates in app terminated state

### Expected results

location streaming on app terminated state

### Actual results

Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter.baseflow.com/geolocator_updates_android.

### Code sample

Code sample

```dart
locationSettings = AndroidSettings(
accuracy: LocationAccuracy.high,
// distanceFilter: 3,
forceLocationManager: true,
intervalDuration: const Duration(seconds: 1),
//(Optional) Set foreground notification config to keep the app alive
//when going to the background
foregroundNotificationConfig:
const ForegroundNotificationConfig(
notificationText:
"App will continue to receive your location even when you are in Background.",
notificationTitle: "Running in Background",
notificationIcon: AndroidResource(name: 'ic_launcher', defType: 'mipmap'),
enableWakeLock: true,
enableWifiLock: true,
setOngoing: true
)
);

positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position? position) {
if (position?.isValid ?? false) {
this.position = position!;
position.saveLocation();
}
if (kDebugMode) print(position?.toJson());
});

```

### Screenshots or video

Screenshots or video demonstration

[Upload media here]

### Version

10.1.0

### Flutter Doctor output

Doctor output

```console
[✓] Flutter (Channel stable, 3.13.9, on macOS 14.1.1 23B81 darwin-arm64, locale en-IN)
• Flutter version 3.13.9 on channel stable at /Users/pankaj/Desktop/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d211f42860 (4 weeks ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/pankaj/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/pankaj/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.14.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.1.1 23B81 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.159
! Error: Browsing on the local area network for Pankaj’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
• All expected network resources are available.

• No issues found!
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the terminated-app location-stream scenario from the provided AndroidSettings sample and inspect the flutter.baseflow.com/geolocator_updates_android channel lifecycle around the detached FlutterJNI error. Done means location updates continue in the terminated state without the platform-message failure, with behavior verified on the reported Android setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, flutter
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.