Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26163

Android: Ti.Geolocation - Exception when using FusedLocationProvider

    Details

      Description

      Customer's app has an Android service to get location data in the background.
      I'm using SDK 7.1.2 cherrypicked by Hans Knöchel

      While testing the app I haven´t found any problem but In Google play console I'm encountering the following exception once or twice a day:

      Real-time crashes
      java.lang.NullPointerException
      ti.modules.titanium.geolocation.android.FusedLocationProvider$PlayServices.registerLocationProvider

      {{java.lang.NullPointerException:
      at com.google.android.gms.common.internal.zzbo.zzb (Unknown Source:8)
      at com.google.android.gms.internal.zzbea.zzb (Unknown Source:2)
      at com.google.android.gms.location.FusedLocationProviderClient.requestLocationUpdates (Unknown Source:14)
      at ti.modules.titanium.geolocation.android.FusedLocationProvider$PlayServices.registerLocationProvider (FusedLocationProvider.java:228)
      at ti.modules.titanium.geolocation.android.FusedLocationProvider.registerLocationProvider (FusedLocationProvider.java:93)
      at ti.modules.titanium.geolocation.GeolocationModule.registerLocationProvider (GeolocationModule.java:723)
      at ti.modules.titanium.geolocation.GeolocationModule.doEnableLocationProviders (GeolocationModule.java:789)
      at ti.modules.titanium.geolocation.GeolocationModule.enableLocationProviders (GeolocationModule.java:760)
      at ti.modules.titanium.geolocation.GeolocationModule.eventListenerAdded (GeolocationModule.java:575)
      at org.appcelerator.kroll.KrollProxy.handleMessage (KrollProxy.java:1151)
      at ti.modules.titanium.geolocation.GeolocationModule.handleMessage (GeolocationModule.java:263)
      at android.os.Handler.dispatchMessage (Handler.java:101)
      at org.appcelerator.kroll.common.TiMessenger.sendMessage (TiMessenger.java:322)
      at org.appcelerator.kroll.KrollProxy.onHasListenersChanged (KrollProxy.java:982)
      at org.appcelerator.kroll.KrollObject.setHasListenersForEventType (KrollObject.java:73)
      at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke (Native Method)
      at org.appcelerator.kroll.runtime.v8.V8Function.callSync (V8Function.java:55)
      at org.appcelerator.kroll.runtime.v8.V8Function.handleMessage (V8Function.java:80)
      at android.os.Handler.dispatchMessage (Handler.java:101)
      at android.os.Looper.loop (Looper.java:164)
      at android.app.ActivityThread.main (ActivityThread.java:6944)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)}}


      My code

      exports.startLocationManager = function() {
      	if (OS_ANDROID) {
       
      		Ti.Geolocation.Android.manualMode = true;
       
      		var geoProviderGPS = Ti.Geolocation.Android.createLocationProvider({
      			minUpdateTime : 60,
      			name : Ti.Geolocation.PROVIDER_GPS
      		});
      		Ti.Geolocation.Android.addLocationProvider(geoProviderGPS);
       
      		var geoProviderNetwork = Ti.Geolocation.Android.createLocationProvider({
      			minUpdateTime : 60,
      			name : Ti.Geolocation.PROVIDER_NETWORK
      		});
      		Ti.Geolocation.Android.addLocationProvider(geoProviderNetwork);
       
      		var geoRuleGPS = Ti.Geolocation.Android.createLocationRule({
      			minAge : 60000,
      			provider : Ti.Geolocation.PROVIDER_GPS,
      		});
      		Ti.Geolocation.Android.addLocationRule(geoRuleGPS);
       
      		var geoRuleNetwork = Ti.Geolocation.Android.createLocationRule({
      			minAge : 60000,
      			provider : Ti.Geolocation.PROVIDER_NETWORK,
      		});
      		Ti.Geolocation.Android.addLocationRule(geoRuleNetwork);
      	}
       
      	Ti.Geolocation.addEventListener('location', exports.locationCallback);
      };
      

        Attachments

          Activity

            People

            • Assignee:
              gmathews Gary Mathews
              Reporter:
              pakoartal@gmail.com Francisco Carlos Artal Barba
              Reviewer:
              Joshua Quick
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-6425
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code