Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap/Cordova geolocation not working on Android
    text
    copied!<p>I'm having a trouble to get Geolocation working on Android in both emulator (even when I <code>geo fix</code> over telnet) and on device. Works on iOS, WP8 and in the browser.</p> <p>When I ask device for location using the following code, I always get an error (in my case custom <code>Retrieving your position failed for unknown reason.</code> with <code>null</code> both error code and error message).</p> <p>Related code:</p> <pre><code> successHandler = (position) -&gt; resolve App.Location.create lat: position.coords.latitude lng: position.coords.longitude errorHandler = (error) -&gt; error = switch error.code when 1 App.LocationError.create message: 'You haven\'t shared your location.' when 2 App.LocationError.create message: 'Couldn\'t detect your current location.' when 3 App.LocationError.create message: 'Retrieving your position timeouted.' else App.LocationError.create message: 'Retrieving your position failed for unknown reason. Error code: ' + error.code + '. Error message: ' + error.message reject(error) options = maximumAge: Infinity # I also tried with 0 timeout: 60000 enableHighAccuracy: true navigator.geolocation.getCurrentPosition(successHandler, errorHandler, options) </code></pre> <p>platforms/android/AndroidManifest.xml</p> <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt; </code></pre> <p>www/config.xml (just in case)</p> <pre><code>&lt;feature name="Geolocation"&gt; &lt;param name="android-package" value="org.apache.cordova.GeoBroker" /&gt; &lt;/feature&gt; </code></pre> <p>Using Cordova 3.1.0. Testing on Android 4.2. Plugin installed. Cordova.js included in index.html (other plugins like InAppBrowser are working fine).</p> <pre><code>$ cordova plugins ls [ 'org.apache.cordova.console', 'org.apache.cordova.device', 'org.apache.cordova.dialogs', 'org.apache.cordova.geolocation', 'org.apache.cordova.inappbrowser', 'org.apache.cordova.vibration' ] </code></pre> <p>I'm clueless. Am I missing something?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload