Ich erhalte den Fehler, wenn ich versuche, den Standort im Hintergrundprozess abzurufen , sodass das Plugin mit ausgeführt wird :
Failed to handle method call
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
Hier ist ein Stacktrace:
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): Failed to handle method call
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(Unknown Source:12)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(Unknown Source:5)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source:94)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(Unknown Source:3)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source:93)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.baseflow.googleapiavailability.GoogleApiAvailabilityPlugin.onMethodCall(GoogleApiAvailabilityPlugin.java:105)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#flutter.baseflow.com/google_api_availability/methods( 5234): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Ich habe eine Beispiel-App erstellt, um das Problem zu reproduzieren: https://github.com/estevez-dev/sample_flutter_app
Es ist für die Ausführung in Gitpod vorkonfiguriert. Tippen Sie einfach auf die schwebende Schaltfläche, um die Hintergrundaufgabe zu starten, und Sie erhalten eine Ausnahme für getCurrentPosition
.
Bitte beachten Sie, dass die App keine Standortberechtigung anfordert. Sie müssen dies manuell in den Android-Einstellungen zulassen.
Plugin-Version: 5.3.0
Plattform:
Vielen Dank für die Übermittlung dieses Problems und des ausführlichen Codebeispiels und der Fehlerbeschreibung. Ich werde das prüfen und versuchen, bald eine Lösung bereitzustellen.
Ich habe das gleiche Problem, findest du bitte eine Lösung?
@walide67 , noch keine Lösung.
@walide67 , noch keine Lösung.
Haben Sie eine Lösung, um den Standort im Hintergrund oder Vordergrund mit Flattern zu verfolgen?
Bitte um Hilfe, da meine Arbeit eingestellt wurde
Dieses Problem sollte nun behoben sein, wir haben einen Hotfix für das google_api_availability
Plugin (von dem geolocator
abhängig ist) veröffentlicht, das die Nullzeiger-Ausnahme löst.
Da das google_api_availability
als Hotfix veröffentlicht wurde, sollte es automatisch übernommen werden, aber wenn Sie sicher sein wollen, aktualisieren Sie bitte auf geolocator
Version 5.3.1.
Kann bestätigen, dass es funktioniert! Vielen Dank!