flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Bug]: App is crashing when get location

Open OsamaQureshi796 opened this issue 7 months ago • 12 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [x] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Steps to reproduce

I just run app on huawei mobile and it crashed after sometime and when i looked at logs i found some exeception given bellow.

Expected results

App should not crashed.

Actual results

App is crashed and throw bellow exception

Code sample

Code sample
[Paste your code here]

Screenshots or video

E/AndroidRuntime(30278): FATAL EXCEPTION: main E/AndroidRuntime(30278): Process: com.dotcoder.badr_driver_app, PID: 30278 E/AndroidRuntime(30278): java.lang.RuntimeException: Unable to instantiate receiver com.baseflow.geolocator.location.GeolocatorBroadcastReceiver: java.lang.ClassNotFoundException: Didn't find class "com.baseflow.geolocator.location.GeolocatorBroadcastReceiver" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.dotcoder.badr_driver_app-BLWDWSi6Ag69UZPb-NH9og==/base.apk"],nativeLibraryDirectories=[/data/app/com.dotcoder.badr_driver_app-BLWDWSi6Ag69UZPb-NH9og==/lib/arm64, /data/app/com.dotcoder.badr_driver_app-BLWDWSi6Ag69UZPb-NH9og==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]] E/AndroidRuntime(30278): at android.app.ActivityThread.handleReceiver(ActivityThread.java:3982) E/AndroidRuntime(30278): at android.app.ActivityThread.access$2300(ActivityThread.java:273) E/AndroidRuntime(30278): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2050) E/AndroidRuntime(30278): at android.os.Handler.dispatchMessage(Handler.java:112) E/AndroidRuntime(30278): at android.os.Looper.loop(Looper.java:216) E/AndroidRuntime(30278): at android.app.ActivityThread.main(ActivityThread.java:7625) E/AndroidRuntime(30278): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(30278): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) E/AndroidRuntime(30278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) E/AndroidRuntime(30278): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.baseflow.geolocator.location.GeolocatorBroadcastReceiver" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.dotcoder.badr_driver_app-BLWDWSi6Ag69UZPb-NH9og==/base.apk"],nativeLibraryDirectories=[/data/app/com.dotcoder.badr_driver_app-BLWDWSi6Ag69UZPb-NH9og==/lib/arm64, /data/app/com.dotcoder.badr_driver_app-BLWDWSi6Ag69UZPb-NH9og==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]] E/AndroidRuntime(30278): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) E/AndroidRuntime(30278): at java.lang.ClassLoader.loadClass(ClassLoader.java:379) E/AndroidRuntime(30278): at java.lang.ClassLoader.loadClass(ClassLoader.java:312) E/AndroidRuntime(30278): at android.app.AppComponentFactory.instantiateReceiver(AppComponentFactory.java:84) E/AndroidRuntime(30278): at androidx.core.app.CoreComponentFactory.instantiateReceiver(CoreComponentFactory.java:59) E/AndroidRuntime(30278): at android.app.ActivityThread.handleReceiver(ActivityThread.java:3975) E/AndroidRuntime(30278): ... 8 more I/Process (30278): Sending signal. PID: 30278 SIG: 9

Version

10.1.0

Flutter Doctor output

[✓] Flutter (Channel stable, 3.24.5, on macOS 15.4.1 24E263 darwin-arm64, locale en-QA) • Flutter version 3.24.5 on channel stable at /Users/badrtechnologyllc/fvm/versions/3.24.5 • Upstream repository https://github.com/flutter/flutter.git • Framework revision dec2ee5c1f (6 months ago), 2024-11-13 11:13:06 -0800 • Engine revision a18df97ca5 • Dart version 3.5.4 • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/badrtechnologyllc/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • 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.6b802.4-9586694) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16E140 • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2022.2) • 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.6b802.4-9586694)

[✓] VS Code (version 1.80.1) • VS Code at /Users/badrtechnologyllc/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.110.0

[✓] Connected device (5 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator) • iPhone (2) (mobile) • 00008030-001A68540CF8802E • ios • iOS 18.4.1 22E252 • macOS (desktop) • macos • darwin-arm64 • macOS 15.4.1 24E263 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.4.1 24E263 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 135.0.7049.116 ! Error: Browsing on the local area network for Med-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) ! Error: Browsing on the local area network for 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) ! Error: Browsing on the local area network for iPhone (2). 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.

OsamaQureshi796 avatar May 10 '25 14:05 OsamaQureshi796

Dear @OsamaQureshi796,

It looks like you are on a very old version of geolocator. Is it possible to update to a newer version? I don't know if this is the problem but the bug might be fixed in newer versions.

Kind regards,

TimHoogstrate avatar May 12 '25 13:05 TimHoogstrate

Dear @TimHoogstrate ,

I really appreciate your response. I'm migrating it to the new version and i'll let you know.

Thanks

OsamaQureshi796 avatar May 12 '25 13:05 OsamaQureshi796

Same is happening to me with geolocator: ^14.0.0 and [√] Flutter (Channel stable, 3.29.3, on Microsoft Windows [Versi¢n 10.0.19045.5737], locale es-ES)

Zirialk avatar May 12 '25 19:05 Zirialk

me too, if accuracy =LocationAccuracy.low App had crashed

jiang111 avatar May 15 '25 05:05 jiang111

Dear @jiang111 or @Zirialk or @OsamaQureshi796,

Can anyone post the location settings that you use when the crash happens AND how you reproduce this? Similar to:

final LocationSettings locationSettings = LocationSettings(
  accuracy: LocationAccuracy.high,
  distanceFilter: 100,
);

Position position = await Geolocator.getCurrentPosition(locationSettings: locationSettings);

Kind regards

TimHoogstrate avatar May 16 '25 08:05 TimHoogstrate

Dear @jiang111 or @Zirialk or @OsamaQureshi796,

Can anyone post the location settings that you use when the crash happens AND how you reproduce this? Similar to:

final LocationSettings locationSettings = LocationSettings(
  accuracy: LocationAccuracy.high,
  distanceFilter: 100,
);

Position position = await Geolocator.getCurrentPosition(locationSettings: locationSettings);

Kind regards

AndroidSettings androidSettings = AndroidSettings(accuracy: LocationAccuracy.low, forceLocationManager: true);
var position = await Geolocator.getCurrentPosition(
locationSettings: androidSettings,
);

After I restarted the phone, I found that the crash was not necessary.

jiang111 avatar May 16 '25 08:05 jiang111

Dear @jiang111 @Zirialk @OsamaQureshi796,

I can't reproduce the issue for now. But be sure to add the following in your manifest:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

I need to update the example app because the example app lacks the appropriate permissions.

Kind regards,

TimHoogstrate avatar May 19 '25 09:05 TimHoogstrate

Dear @TimHoogstrate i do have these permissions in the app but it still crashing in some huawei mobiles.

OsamaQureshi796 avatar May 19 '25 09:05 OsamaQureshi796

Please have a look at the video. there is also this bug happening.

https://github.com/user-attachments/assets/db94489d-2a32-427d-8556-28f47b1ada44

OsamaQureshi796 avatar May 19 '25 09:05 OsamaQureshi796

@OsamaQureshi796, it looks like you use version geolocator version 10? This is an old version. Can you upgrade to a newer version?

Kind regards,

TimHoogstrate avatar May 19 '25 11:05 TimHoogstrate

Dear @TimHoogstrate

i'm using geolocator_android: ^4.6.0 because i've given update last time and my app was crashing and then i found out that this version is stable version but now i'm in doubt if i update app to latest version and start crashing.

OsamaQureshi796 avatar May 19 '25 12:05 OsamaQureshi796

Dear @OsamaQureshi796,

I think you should upgrade Flutter to a newer (3.29 and above) version and migrate Gradle in order to use geolocator_android 5.0.0.

Kind regards,

TimHoogstrate avatar Jun 03 '25 12:06 TimHoogstrate

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

github-actions[bot] avatar Jun 17 '25 13:06 github-actions[bot]