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

Android: Ti.Geolocation - Exception when calling Ti.Geolocation.hasLocationPermissions()

    Details

    • Story Points:
      3
    • Sprint:
      2018 Sprint 06 SDK

      Description

      Issue

      Customer's app has an android service to get location data in the background. It is encountering an exception when it calls Ti.Geolocation.hasLocationPermissions():

      They are receiving the following error:

      03-19 08:43:48.855 2764 2764 E TiApplication: (main) [6,1875] No valid root or current activity found for application instance
      03-19 08:43:48.855 2764 2764 E KrollProxy: (main) [0,1875] Error creating proxy
      03-19 08:43:48.855 2764 2764 E KrollProxy: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
      03-19 08:43:48.855 2764 2764 E KrollProxy: at com.google.android.gms.common.zzo.isGooglePlayServicesAvailable(Unknown Source:4)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at com.google.android.gms.common.zze.isGooglePlayServicesAvailable(Unknown Source:0)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source:0)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at ti.modules.titanium.geolocation.android.FusedLocationProvider$PlayServices.available(FusedLocationProvider.java:184)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at ti.modules.titanium.geolocation.android.FusedLocationProvider.hasPlayServices(FusedLocationProvider.java:80)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at ti.modules.titanium.geolocation.android.FusedLocationProvider.<init>(FusedLocationProvider.java:61)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at ti.modules.titanium.geolocation.GeolocationModule.<init>(GeolocationModule.java:219)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at java.lang.Class.newInstance(Native Method)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at org.appcelerator.kroll.KrollProxy.createProxy(KrollProxy.java:137)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:187)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:325)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at android.os.Handler.dispatchMessage(Handler.java:102)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at android.os.Looper.loop(Looper.java:164)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at android.app.ActivityThread.main(ActivityThread.java:6494)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at java.lang.reflect.Method.invoke(Native Method)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
      03-19 08:43:48.855 2764 2764 E KrollProxy: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
      03-19 08:43:48.855 2764 2764 E JavaObject: !!! OH NO! We tried to grab a Java Object back out of the reference table, but it must have been GC'd, because it's null! Key: 15
      03-19 08:43:48.855 2764 2764 I TiAPI : We do not have location permissions. Exiting.

      The exception does not seem to make the service crash, but it doesn't think that it has location permissions (which it definitely does). So they are not getting any location data.

      Code to create Android service:

      var location_service_intent = Ti.Android.createServiceIntent( { url: 'LocationService.js' } ); 
      location_service_intent.putExtra('interval', 600000); 
       
      if (!Ti.Android.isServiceRunning(location_service_intent)) { 
      Ti.Android.startService(location_service_intent); 
      } 

      Service Code:

      Uses a module to do all the location detection and updating with the back-end service provider.

      Titanium.API.info("[LocationService] loaded"); 
       
      var WxAlertSubscriptionUpdater = require ('/util/WxAlertSubscriptionUpdater'); 
      WxAlertSubscriptionUpdater.register(); 
      

      Additional information
      • issue not in SDK 7.0.2
      • the WxAlertSubscriptionUpdater module is shared by the app and the service; the app doesn't have this problem when it talks to the Geolocation module
      • They have been unable to replicate this problem with a minimal test app; it's possible that a test app is too small to make garbage collection happen?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                vvazquezmontero Victor Vazquez Montero
                Reviewer:
                Yordan Banev
              • Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code