Exception upon call CrossGeolocator GetPositionAsync

Anna_nAnna_n ILMember ✭✭

I receive the exception on third or fourth time of this call

My code is :

    private async void GetCurrentLocation() 
    {
        var locator = CrossGeolocator.Current;       
        TimeSpan timeoutMilliseconds = new TimeSpan(10000);
        Plugin.Geolocator.Abstractions.Position position = null;
        try
        {
            position = await locator.GetPositionAsync(timeoutMilliseconds) ;
        }
        catch (Exception e)
        {
            if (e is TaskCanceledException)
            {.....
            }
        }

        if (position != null)
            .....
    }

The exception code is

01-12 15:25:06.543 E/mono (28227): Unhandled Exception:
01-12 15:25:06.543 E/mono (28227): Java.Lang.IllegalArgumentException: invalid listener: null
01-12 15:25:06.543 E/mono (28227): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.543 E/mono (28227): at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in :0
01-12 15:25:06.543 E/mono (28227): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in :0
01-12 15:25:06.543 E/mono (28227): at Android.Locations.LocationManager.RemoveUpdates (Android.Locations.ILocationListener listener) [0x00036] in :0
01-12 15:25:06.543 E/mono (28227): at Plugin.Geolocator.GeolocatorImplementation+<>c__DisplayClass32_0.b__0 () [0x00004] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocatorImplementation.cs:148
01-12 15:25:06.543 E/mono (28227): at Plugin.Geolocator.GeolocationSingleListener.Finish (Android.Locations.Location location) [0x00000] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocationSingleListener.cs:115
01-12 15:25:06.543 E/mono (28227): at Plugin.Geolocator.GeolocationSingleListener.TimesUp (System.Object state) [0x00039] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocationSingleListener.cs:108
01-12 15:25:06.543 E/mono (28227): at System.Threading.Timer+Scheduler.TimerCB (System.Object o) [0x00007] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.543 E/mono (28227): at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.543 E/mono (28227): at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.543 E/mono (28227): at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.543 E/mono (28227): --- End of managed Java.Lang.IllegalArgumentException stack trace ---
01-12 15:25:06.543 E/mono (28227): java.lang.IllegalArgumentException: invalid listener: null
01-12 15:25:06.543 E/mono (28227): at android.location.LocationManager.checkListener(LocationManager.java:1606)
01-12 15:25:06.543 E/mono (28227): at android.location.LocationManager.removeUpdates(LocationManager.java:852)
01-12 15:25:06.543 E/mono (28227): at dalvik.system.NativeStart.run(Native Method)
01-12 15:25:06.543 E/mono (28227):
01-12 15:25:06.551 E/mono-rt (28227): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: invalid listener: null
01-12 15:25:06.551 E/mono-rt (28227): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.551 E/mono-rt (28227): at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in :0
01-12 15:25:06.551 E/mono-rt (28227): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in :0
01-12 15:25:06.551 E/mono-rt (28227): at Android.Locations.LocationManager.RemoveUpdates (Android.Locations.ILocationListener listener) [0x00036] in :0
01-12 15:25:06.551 E/mono-rt (28227): at Plugin.Geolocator.GeolocatorImplementation+<>c__DisplayClass32_0.b__0 () [0x00004] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocatorImplementation.cs:148
01-12 15:25:06.551 E/mono-rt (28227): at Plugin.Geolocator.GeolocationSingleListener.Finish (Android.Locations.Location location) [0x00000] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocationSingleListener.cs:115
01-12 15:25:06.551 E/mono-rt (28227): at Plugin.Geolocator.GeolocationSingleListener.TimesUp (System.Object state) [0x00039] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocationSingleListener.cs:108
01-12 15:25:06.551 E/mono-rt (28227): at System.Threading.Timer+Scheduler.TimerCB (System.Object o) [0x00007] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.551 E/mono-rt (28227): at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.551 E/mono-rt (28227): at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.551 E/mono-rt (28227): at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
01-12 15:25:06.551 E/mono-rt (28227): --- End of managed Java.Lang.IllegalArgumentException stack trace ---
01-12 15:25:06.551 E/mono-rt (28227): java.lang.IllegalArgumentException: invalid listener: null
01-12 15:25:06.551 E/mono-rt (28227): at android.location.LocationManager.checkListener(LocationManager.java:1606)
01-12 15:25:06.551 E/mono-rt (28227): at android.location.LocationManager.removeUpdates(LocationManager.java:852)
01-12 15:25:06.551 E/mono-rt (28227): at dalvik.system.NativeStart.run(Native Method)

Answers

  • prashantvcprashantvc USXamarin Team Xamurai

    Could you share the following information? It will help us to troubleshoot the issue

    Version Number of Plugin:
    Device Tested On:
    Simulator Tested On:
    Version of VS:
    Version of Xamarin:
    Versions of other things you are using:

  • Anna_nAnna_n ILMember ✭✭

    Hello,
    Plugin - Xam.Plugin.Geolocator, version 4.1.2
    Device - Galaxy Nexus, Android 4.3
    Tested on physical device
    Visual Studio 15.2
    Xamarin 4.5, built -in Visual Studio

    It happens if the GetCurrentLocation is called on page appearing.
    If I remove it from the page appearing callback and call explicitly ( ex., on button pressed ) - the crash disappeared.

    Thanks,
    Anna

  • Anna_nAnna_n ILMember ✭✭

    Any updates relating to this issue?

Sign In or Register to comment.