Last Updated
Viewed 07 Times

Trying to get an android version of a react-native 0.61.2 app running...

The app intends to use react-native-geolocation-service but can not get past this error:

"Error: @react-native-community/geolocation: NativeModule.RNCGeolocation is null."

enter image description here

I understand that react-native-geolocation-service uses @react-native-community/geolocation on iOS but this is android. I have searched the entire project for the string RNCGeolocation and it's not there. How can I get running with react-native-geolocation-service on android?

Similar Question 1 : React Native Android GeoLocation

I am trying to get the User's location in an Android React Native application. I've started by following the React Native Geolocation Tutorial but am not having any luck.

I have added the appropriate permissions to the Android project and inserted this code in the react native app:

  componentDidMount() {

      (position) => {
        var initialPosition = JSON.stringify(position);
      (error) => alert(error.message),
      {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
    console.log("Initial position: " + this.state.initialPosition)


I also have the initialPosition variable defined as 'unknown' just like in the tutorial. When the example runs, the initialPosition variable prints unknown. Then about 5 seconds later, the alert shows an 'undefined' error.

I am a bit confused as to what is going on because the error is null. Perhaps I am instantiating the "geolocation" incorrectly? Unfortunatly I am not able to find much information on this through searches so any help is appreciated.

I'm trying to get the current user location in Android with React Native. I have written the following snippet in the App.js file:

import React, { Component } from "react";
import {
} from "react-native";

export default class App extends Component {
  state = {
    location: null

  findCoordinates = () => {
      position => {
        const location = JSON.stringify(position);

        this.setState({ location });
      error => alert(error.message),
      { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }


  render() {
    return (
      <View style={styles.container}>
        <TouchableOpacity onPress={this.findCoordinates}>
          <Text style={styles.welcome}>Find My Coords?</Text>
          <Text>Location: {this.state.location}</Text>

const styles = StyleSheet.create({
  ... some style ...

Since I use an Android emulator, I have also added the following line in the AndroidManifest.xml file located in android\app\src\main, just above the application tag:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

When I run it, no request for sharing the GPS location pops up and also the getCurrentPosition function seems to be just skipped. The state is not updated, no error is displayed and the alert "SKIPPED" appears.

That is what I see on the screen after the "SKIPPED" alert is dismissed:

enter image description here

What am I missing here?

Similar Question 3 : React-native Android geolocation

I need to detect user's geolocation on React-native Android but the current implementation supports only iOS. I haven't found any tutorials or related questions anywhere.

I have tried to create my own Android native component for this. I have tried it with the emulator (setting some coordinates via commandline) and with a phone but there is no gps icon in the action bar and the react callback has no data in it.

I'm trying to get the last known location immediately and I'm also setting up an event listener for updates.

public class GeoLocation extends ReactContextBaseJavaModule implements
    GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {

protected static final String TAG = "GeoLocation";
protected GoogleApiClient mGoogleApiClient;
protected Location mLastLocation;

public GeoLocation(ReactApplicationContext reactContext) {

public String getName() {
    return "GeoLocation";

protected synchronized void buildGoogleApiClient() {
    mGoogleApiClient = new GoogleApiClient.Builder(getReactApplicationContext())

public void onConnected(Bundle connectionHint) {

    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    //WritableMap params = Arguments.createMap();

    //Can I use ConcurrentHashMap instead of WritableMap?
    ConcurrentHashMap<String, String> params = new ConcurrentHashMap();
    params.put("lastLocation", mLastLocation.toString());
    sendEvent(getReactApplicationContext(), "geoCoordsChanged", params);

public void onConnectionFailed(ConnectionResult result) {
    Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + result.getErrorCode());

public void onConnectionSuspended(int cause) {

public void getLastLocation(Callback success,Callback err){
    try {
        String msg = "No location found yet";

        if(mLastLocation != null){
            msg = mLastLocation.toString();

    } catch (Exception e) {

private void sendEvent(ReactContext reactContext,
                       String eventName,
                       @Nullable ConcurrentHashMap<String, String> params) {
  try {
          .emit(eventName, params);
  } catch(Exception e){



<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


    <meta-data android:name=""
               android:value="@integer/google_play_services_version" />

I haven't found anything relevant from the logcat logs either. Any tips what is wrong with this code or any kind of solution for getting geocoordinates would be great!

Similar Question 5 (1 solutions) : React-Native Geolocation API on Background (android)

Similar Question 6 (1 solutions) : GeoLocation React Native

Similar Question 9 (1 solutions) : React-Native Geolocation of other devices