title: Cordova geolocation not working on Android
body: <p>I want to use geolocation on Android. I write app in Apache Cordova.
  Geolocation do not work both on andoid pc emulator and andoid phone.</p>
  
  <p>I try <a href="http://cordova.apache.org/docs/en/2.4.0/cordova_geolocation_geolocation.md.html#geolocation.getCurrentPosition_full_example" rel="nofollow">http://cordova.apache.org/docs/en/2.4.0/cordova_geolocation_geolocation.md.html#geolocation.getCurrentPosition_full_example</a> 
  and <a href="http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation" rel="nofollow">http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation</a></p>
  
  <p>My platforms/android/AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" android:windowSoftInputMode="adjustPan" package="net.example.test" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &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;
      &lt;uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" /&gt;
      &lt;application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"&gt;
          &lt;activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="Test" android:theme="@android:style/Theme.Black.NoTitleBar"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>www/config.xml:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;widget id="net.example.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"&gt;
      &lt;name&gt;Test&lt;/name&gt;
      &lt;description&gt;
          A sample Apache Cordova application that responds to the deviceready event.
      &lt;/description&gt;
      &lt;author email="dev@cordova.apache.org" href="http://cordova.io"&gt;
          Apache Cordova Team
      &lt;/author&gt;
      &lt;content src="index.html" /&gt;
      &lt;access origin="*" /&gt;
      &lt;feature name="Geolocation"&gt;
          &lt;param name="android-package" value="org.apache.cordova.GeoBroker" /&gt;
      &lt;/feature&gt;
  &lt;/widget&gt;
  </code></pre>
  
  <p>I have cordova 3.3.1 and these plugins:</p>
  
  <pre><code>$ cordova -v
  3.3.1-0.4.2
  $ cordova plugin ls
  [ 'org.apache.cordova.console',
    'org.apache.cordova.device',
    'org.apache.cordova.dialogs',
    'org.apache.cordova.geolocation' ]
  $ 
  </code></pre>
  
  <p>I find a lot of question on the Internet (on stackoverflow too), but all did not work :-(</p>
  
  <p>Do you have any idea, where I have an error?</p>
  
  <hr>
  
  <p>Update: </p>
  
  <p>Now I have in index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;&lt;head&gt;
      &lt;script type="text/javascript" charset="utf-8" src="cordova.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" charset="utf-8"&gt;
  
      // Wait for device API libraries to load
      document.addEventListener("deviceready", onDeviceReady, false);
  
      // device APIs are available
      function onDeviceReady() {
          console.log('in onDeviceReady()');
          navigator.geolocation.getCurrentPosition(onSuccess, onError);
      }
  
      // onSuccess Geolocation
      function onSuccess(position) {
          console.log('in onSuccess()');
          console.log(position.coords.latitude);
          console.log(position.coords.longitude);
          var element = document.getElementById('geolocation');
          element.innerHTML = 'Latitude: '           + position.coords.latitude              + '&lt;br /&gt;' +
                              'Longitude: '          + position.coords.longitude             + '&lt;br /&gt;' +
                              'Altitude: '           + position.coords.altitude              + '&lt;br /&gt;' +
                              'Accuracy: '           + position.coords.accuracy              + '&lt;br /&gt;' +
                              'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '&lt;br /&gt;' +
                              'Heading: '            + position.coords.heading               + '&lt;br /&gt;' +
                              'Speed: '              + position.coords.speed                 + '&lt;br /&gt;' +
                              'Timestamp: '          + position.timestamp                    + '&lt;br /&gt;';
      }
  
      // onError Callback receives a PositionError object
      function onError(error) {
          console.log('in onError()');
          console.log(error.code);
          console.log(error.message);
          alert('code: '    + error.code    + '\n' +
                'message: ' + error.message + '\n');
      }
  
      &lt;/script&gt;
    &lt;/head&gt;&lt;body&gt;&lt;p id="geolocation"&gt;Finding geolocation...&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>After I run app in Android emulator and run logcat, I see:</p>
  
  <pre><code>$ telnet localhost 5554
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  Android Console: type 'help' for a list of commands
  OK
  geo fix 50.60 10.20
  OK
  
  $ adb logcat Cordova:* DroidGap:* CordovaLog:* *:S
  - waiting for device -
  I/CordovaLog(  805): Changing log level to DEBUG(3)
  I/CordovaLog(  805): Found start page location: index.html
  I/CordovaLog(  805): Changing log level to DEBUG(3)
  I/CordovaLog(  805): Found start page location: index.html
  D/CordovaLog(  805): file:///android_asset/www/index.html: Line 11 : in onDeviceReady()
  D/CordovaLog(  805): file:///android_asset/www/index.html: Line 33 : in onError()
  D/CordovaLog(  805): file:///android_asset/www/index.html: Line 34 : null
  </code></pre>
  
  <p>Can you please help me?</p>