Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13385

Geolocation doesn't work on Android 8.0 (Oreo)

    XMLWordPrintableJSON

    Details

      Description

      With a Google LG Nexus 5X and I can't manage to make getCurrentPosition() work.

      I have Wi-Fi on, Location on high accuracy, Mobile data on, even Bluetooth on, but nothing.

      You can replicate by running this code in the Chrome Dev console (via Remote devices):

        var geoOptions = {
           timeout: 10 * 1000
        }
      
        var geoSuccess = function(position) {
          alert('Success! Lat: ' + position.coords.latitude + '  . Long: ' + position.coords.longitude);
        };
        var geoError = function(error) {
          alert('Error occurred. Error code: ' + error.code);
          // error.code can be:
          //   0: unknown error
          //   1: permission denied
          //   2: position unavailable (error response from location provider)
          //   3: timed out
        };
      
        navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions);
      

      I also managed to reproduce with a cordova plugin and ionic native showcase app:

      1. https://play.google.com/store/apps/details?id=br.com.marcioggs.cordovashowcase&rdid=br.com.marcioggs.cordovashowcase
      2. https://play.google.com/store/apps/details?id=com.ionichelper.ionic2native&rdid=com.ionichelper.ionic2native
        (though no error appears)

      Code the 1st app is here: https://github.com/michaelrbk/showCaseCordova/blob/master/www/js/geolocation.js

      Trying a phone with Android 6 is fine.

      Could this be related to this?
      https://developer.android.com/about/versions/oreo/background-location-limits.html

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gianpaj Gianfranco Palumbo
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: