NativeScript / nativescript-geolocation

Geolocation plugin to use for getting current location, monitor movement, etc
Apache License 2.0
139 stars 76 forks source link

_getLocationCallback() from plugin crashes the app #264

Open deindesignpl opened 4 years ago

deindesignpl commented 4 years ago

Hi, firstly thanks for great plugin. In works well, but what I noticed is that sometimes _getLocationCallback() crashes NativeScript App.

The error I get is:

NativeScriptException
Calling js method onLocationResult failed
TypeError: Cannot read property 'forEach' of undefined

Here is the stack trace that I managed to log:

com.tns.Runtime in callJSMethodNative
com.tns.Runtime in dispatchCallJSMethodNative at line 1209
com.tns.Runtime in callJSMethodImpl at line 1096
com.tns.Runtime in callJSMethod at line 1083
com.tns.Runtime in callJSMethod at line 1063
com.tns.Runtime in callJSMethod at line 1055
com.tns.gen.com.google.android.gms.location.LocationCallback_vendor_1_498322_ in onLocationResult at line 19
com.google.android.gms.internal.location.zzau in notifyListener at line 4
com.google.android.gms.common.api.internal.ListenerHolder in notifyListenerInternal at line 17
com.google.android.gms.common.api.internal.ListenerHolder$zaa in handleMessage at line 5
android.os.Handler in dispatchMessage at line 106
com.google.android.gms.internal.base.zap in dispatchMessage at line 8
android.os.Looper in loop at line 171
android.app.ActivityThread in main at line 6637
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 518
com.android.internal.os.ZygoteInit in main at line 824

After debugging I found out that it might be something with onLocationResults and getLastLocation() call in: https://github.com/NativeScript/nativescript-geolocation/blob/a8d9a1f0fe73def247796cf14cc5539ece7f5192/src/geolocation.android.ts#L94