Share GPS
Android app for sharing GPS data with mapping applications

Using udev, it's possible to automate setting up of adb and gpsd for USB connections when plugging in the phone. Follow this procedure for setting it up. Note that you will need a systemd based system for this. Most of the popular distros now use this. PLEASE BE SURE YOU HAVE BEEN THROUGH THE MANUAL PROCEDURE AND HAVE IT WORKING BEFORE EXECUTING THIS PROCEDURE. You can find the Linux USB setup here: Linux USB setup .

  1. Grab the following file from the Downloads page: linux-auto.tar.gz
    Unzip in a convenient location.
  2. Have your mobile with USB debugging enabled ready and run as root or sudo.

    [user@tc01 ~]# sudo ./
  3. Follow the prompts during the script. It will perform the following tasks:
    • Check for adb, gpsd, and netstat existing on the system. If it does not find them, you will need to update the file /usr/local/bin/ with locations later.
    • Have you plug the mobile in while listening for information. The script will post what it finds and ask the user if it is correct. This is needed for the udev rule that is created and located at /etc/udev/rules.d/.
    • Ask for a user to run adb as. Running adb as root does not work correctly on some systems. I noticed it will detect the device, but treat it as offline. Use the username you usually login as.
    • The following files are created:
      • /usr/local/bin/
      • /etc/systemd/system/adb-gps.service
      • /etc/udev/rules.d/99-adb_gps_usb.rules
    • Then the systemd daemon control is restarted. Udev rules are reloaded as well.

  4. If the script did not find adb, gpsd, or netstat, edit the file /usr/local/bin/ with the full location to the binaries. The specific ports used for adb need to be edited here as well.

  5. Be sure you have authorized you PC with the phone and have it set to always authorize. Run adb devices and check for the following prompt on your device if it is not set to always authorize

  6. Now it should be possible to unplug and plug back in the phone and have adb and gpsd start automatically. Start the USB connection on Share GPS.
  7. To test things, try using one of the gpsd example clients. Run xgps &and verify Share GPS indicates Connected. You should see coordinates in xgps.


  1. Try running ' start' manually after plugging in the phone and see if that works.
  2. Check the udev rule at '/etc/udev/rules.d/99-adb_gps_usb.rules'. You can use 'lsusb' to check the vendor ID.

  3. Check that the processes are running after plugging in ps -ef | grep adb You should see the script and adb running. If they run shortly and then end, it may indicate adb running as the wrong user. If nothing is happening, check the udev rule for having the correct Vendor and S/N.
  4. If adb is working, check for gpsd: ps -ef | grep gpsd
  5. If things still aren't working, re-check for using the correct ports for your setup.

Additional Notes:

If wanting to support multiple phones, the install script can be run multiple times, there are two important things to consider:

  1. The /usr/local/bin/ script will be overwritten on install. If you have special edits, back up the file.
  2. The udev rule will be overwritten with info from the new phone. To continue to support the old phone, rename the rule to another name in the /etc/udev/rules.d directory. Example:
    mv 99-adb_gps_usb.rules