Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20102] Android 6.0 - 5.1.1.GA - Location permissions missing

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-02-17T14:41:52.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsAndroid
Labelsn/a
ReporterFlavio Lacerda
AssigneeEric Merriman
Created2015-12-03T21:32:31.000+0000
Updated2017-02-17T14:41:58.000+0000

Description

When you try to use Geolocation to discover position (getCurrentPosition), returns error on Android Log: (KrollRuntimeThread) Location permissions missing. The callback is not fired. SDK : 5.1.1.GA Android 6.0 SDK 5.0.2.GA works fine

Comments

  1. Jebun Naher 2015-12-07

    Hello, We tested this issue and observed that getCurrentPosition() is not working as expected on Android 6. On Android 4.4.2 it's working as expected. *Testing Environment:* Titanium SDK version 5.1.1.GA Appcelerator Studio, build: 4.4.0.201511241829 Mac OS X Version = 10.11.1 Architecture = 64bit Node.js Version = 0.12.7 npm Version = 2.11.3 Appcelerator CLI Installer = 4.2.2 Core Package = 5.1.0 Titanium CLI Version = 5.0.5 node-appc Version = 0.2.31 Android device: Nexus 7(android 6) Samsung Tab: Android (4.4.2) *Test Case:*
       var map=require('ti.map');
       var win = Ti.UI.createWindow();
       Titanium.Geolocation.purpose = "Recieve User Location";
       Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
       // Set Distance filter. This dictates how often an event fires based on the distance the device moves. This value is in meters.
       Titanium.Geolocation.distanceFilter = 10;
       //set the mapview with the current location
       var mapview = Titanium.Map.createView({
           mapType: Titanium.Map.STANDARD_TYPE,
           animate:true,
           //region: {latitude:39.30109620906199, longitude:-76.60234451293945, latitudeDelta:0.1, longitudeDelta:0.1},
           regionFit:true,
           userLocation:true,
           visible: true,
       });
       function getLocation(){
       //Get the current position and set it to the mapview
       Titanium.Geolocation.getCurrentPosition(function(e){
               var region={
                   latitude: e.coords.latitude,
                   longitude: e.coords.longitude,
                   animate:true,
                   latitudeDelta:0.001,
                   longitudeDelta:0.001
               };
               mapview.setLocation(region);
       });
       }
       win.add(mapview);
       Titanium.Geolocation.addEventListener('location',function(){
           getLocation();
       });
       win.open();
       
    *Steps to test:* 1. Create a classic project, replace app.js with the above code Build and run the project on android version 4.4.2 and observe that the device location is seen. Now run the project on android 6 and observe that device location is not visible. Thanks.
  2. David Fischer 2016-01-05

    I'm seeing the same error. As far as I can tell, this is still an issue.
  3. David Fischer 2016-01-05

  4. David Fischer 2016-01-05

    Downgrading to 5.0.2.GA and downgrading node.js to 0.12 worked for me.
  5. David Fischer 2016-01-06

    Is it possible to get this ticket re-opened and re-looked at. It was closed out without comment as simply "can't reproduce" but it does seem to be affecting multiple users.
  6. Matthew Hewes 2016-01-17

    Has a workaround other than downgrading to 5.0.2 been found for this? I'm having the issue on 5.1.2.GA as well... Android 6.0 cannot find location. and repeatedly spits out this error: {color:red}[ERROR] : GeolocationModule: (KrollRuntimeThread) [2002,271792] Location permissions missing{color}
  7. Ryan Buening 2016-01-26

    I'm also getting this error on SDK 5.1.2 GA. [ERROR] : GeolocationModule: (KrollRuntimeThread) [9525,9525] Location permissions missing My AndroidManifest has the following location permissions: Trying to run: Titanium.Geolocation.getCurrentPosition(function(e) {
  8. David Vermeir 2016-02-08

    Getting the same error on Nexus 5 with Android 6 and 5.1.2.GA. Reverting to 5.0.2 it works again. Please reopen this ticket! I'm guessing this has something to do with this: http://developer.android.com/training/permissions/requesting.html Since I'm targeting API 23 and running Android 6.0 but I'm not getting a request for location permissions at runtime.
  9. David Vermeir 2016-02-08

    For those of you still waiting for a fix but who don't want to downgrade the Titanium SDK, here's a solution: Since Android 6.0 it's not sufficient to just declare your permissions in the manifest, you have to ask for it at runtime. Translating this to Titanium: {noformat} if(!Titanium.Geolocation.hasLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS)) { Titanium.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS, function(result){ if(!result.success) { //no location permissions flow triggers } else { //do something } }); } {noformat}
  10. James O'Leary 2016-05-03

    Replicated this problem(callback not called on getcurrentposition) Ti SDK 5.2.2 Android 6.0
  11. Chandan Sharma 2016-05-18

    I am also getting same error!!! Callback function getcurrentposition() is not getting called even if Titanium.Geolocation.AUTHORIZATION_ALWAYS permission is granted
  12. Ashraf Abu 2016-06-02

    [~chandan] Did you request the permission at runtime?
  13. Chandan Sharma 2016-06-03

    Yes added runtime permission to access camera like as below: [if(!Titanium.Geolocation.hasLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS)) { Titanium.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS, function(result){ if(!result.success) { //no location permissions flow triggers } else { //do something } }); }]
  14. Ashraf Abu 2016-07-04

    To see which permissions that's really needed and what's not requested, inside Android you can go to: Settings>Apps>"YourAppName">Permissions> If you can see what permission is not used or in use. You can click it to see if it helps. To address this further, in 5.4.0 (future), you can use Ti.Android.requestPermissions() https://github.com/appcelerator/titanium_mobile/blob/ff3acd9a1f1ffcd82a634700e3457ce269e463fe/apidoc/Titanium/Android/Android.yml#L197-L212 Jira for ref: TIMOB-20320

JSON Source