How to add geolocation to your Android app using React Native

TL;DR: Use the rn-geolocation npm package. After you install it, install Google Repository and Google Play Services dependency. Add the plugin to your Android build by changing your settings.gradle and android/app/build.gradle and add the package to your MainActivity.java.

For the past few days I have been developping a React Native app for Android. One of the things I needed for my app was geolocation. I started by trying navigator.geolocation just to figure out that the Geo Location module is a Missing Module in React Native for Android. Since that was not an option, I set out looking for answers:

The ones I found depended on external libraries, so in the end I ended up creating my own rn-geolocation native module for Android. I have to thank Corentin Smith for sharing his Java code with me. I ended up using most of it for my package.

To use the package check the github or npm page, as they have the most up to date information.

Originally published at blog.bamlab.fr on November 11, 2015.

Dev at Sketchfab

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store