react-nativereact-android

getting an error No ViewManager defined for class RCTRawText


I am trying to use geolocation.getcurrentposition and I am getting an error. Below is the screen shot of the error:

enter image description here

below is my App.Js code:

import React, { Component } from 'react';
import { View, Text } from 'react-native';

class GeolocationExample extends Component {
  constructor(props) {
    super(props);

    this.state = {
      latitude: null,
      longitude: null,
      error: null,
    };
  }

  componentDidMount() {
    // Instead of navigator.geolocation, just use Geolocation.
    if (hasLocationPermission) {
        Geolocation.getCurrentPosition(
            (position) => {
                console.log(position);
            },
            (error) => {
                // See error code charts below.
                console.log(error.code, error.message);
            },
            { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
        );
    }
}

  render() {
    return (
      <View style={{ flexGrow: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Latitude: {this.state.latitude}</Text>
        <Text>Longitude: {this.state.longitude}</Text>
        {this.state.error ? <Text>Error: {this.state.error}</Text> : null}
      </View>
    );
  }
}

export default GeolocationExample;

I also made some modification to MainActivity.Java file. Below are the changes that I did in the dependencies section of MainActivity. java

import com.agontuk.RNFusedLocation.RNFusedLocationPackage;
@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
         // new MainReactPackage()
          new RNFusedLocationPackage()
      );
    }

While using the getcUrrentposition, my longitude and latitude are timing out and that is the reason, I am using the workaround. This workaround is with installing the react-native-geolocation -service. The google play service version that I am using is 12.2.21. Below is the image for that:

enter image description here

I also added the dependencies in build.gradle. I inserted the current google play service version in build.gradle

  compile(project(':react-native-geolocation-service')) {
    exclude group: 'com.google.android.gms', module: 'play-services-location'
}
compile 'com.google.android.gms:play-services-location:12.2.21'

above code is timing out when I am trying to get the longitude and latitude of the current position of the user. I made these changes so that my android phone starts showing the longitude and latitude without timing out. I am not sure where this error is coming from. The error is not showing any line numbers.

any help will be greatly appreciated


Solution

  • same problem, but when i tried auto linking i got a warning in Android Studio that package

    com.agontuk.RNFusedLocation

    is deprecated

    so i think react-native-geolocation-service is buggy