A step-by-step guide on how to install @react-native-community/geolocation
The react-native team recently launched react-native v0.6. Surprisingly, the geolocation API was moved to @react-native-community/geolocation, causing a bit of change in how it is used due to its installation. In this article, I’m going to show you how to install it and how to solve a common problem whilst installing it.
Setting up our project
Follow this link to setup your development environment for android, then switch to
React Native CLI Quickstart.
Create a new React Native project
npx react-native init MyGeolocation
Run the line of code in your terminal to start your project
npx react-native run-android
Let’s get started 🔥
@react-native-community/geolocation for android
yarn add @react-native-community/geolocation or
npm install @react-native-community/geolocation
Add user permission to
Go to AndroidManifest.xml in
android/app/src/main/AndroidManifest.xml and add or check here
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Restart your project
npx react-native run-android in your terminal
Note: you might get this error in your terminal
Task :app:mergeDexDebug Failed
this usually occur when you have imported a lot of packages which is unable to fit in a yaml file, which then causes a problem for the multidex builder.
npx react-native run-android and tadaaa 🎉
Is that all?
Yeah! Yeah!! Yeah!!!
Like and share.