homeeondemand / react-native-mapbox-navigation

A navigation UI ready to drop into your React Native application
MIT License
153 stars 118 forks source link

Android - When set shouldSimulateRoute to false app is crashed when open the mapbox navigation. #95

Open ahmedelsayed11 opened 2 years ago

ahmedelsayed11 commented 2 years ago

When trying to implement this package in android and set shouldSimulateRoute to false when open the page of mopbox navigation the app is crashed i don't know why this is happen. Is somebody can help it will be appreciated. in IOS it works fine but this happens in Android only!

"@homee/react-native-mapbox-navigation": "^1.1.0" "react-native": "0.68.2" "react": "17.0.2"

App.js

import React from 'react';
import {Text, View, StyleSheet} from 'react-native';
import MapboxNavigation from '@homee/react-native-mapbox-navigation';

const App = () => {
  return (
    <View style={styles.container}>
      <MapboxNavigation
        origin={[31.407516555348657, 30.02753965945932]}
        destination={[31.20725835904003, 30.010892742780463]}
        shouldSimulateRoute={false}
        showsEndOfRouteFeedback
        onLocationChange={event => {
          const {latitude, longitude} = event.nativeEvent;
        }}
        onRouteProgressChange={event => {
          const {
            distanceTraveled,
            durationRemaining,
            fractionTraveled,
            distanceRemaining,
          } = event.nativeEvent;
        }}
        onError={event => {
          const {message} = event.nativeEvent;
        }}
        onCancelNavigation={() => {
          console.log('Cancel Navigation.....');
          // User tapped the “X” cancel button in the nav UI
          // or canceled via the OS system tray on android.
          // Do whatever you need to here.
        }}
        onArrive={() => {
          // Called when you arrive at the destination.
        }}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {flex: 1},
});

export default App;
Cirff commented 2 years ago

please make sure you added below in AndroidManifest.xml `

inside below tag <applicationandroid:name=".MainApplication" android:label="@string/app_name" and not inside <activity android:name=".MainActivity"

ahmedelsayed11 commented 2 years ago

Yes I have fixed the problem by check permission in android if simulate is false.

abazudosen commented 2 years ago

Yes I have fixed the problem by check permission in android if simulate is false.

PLS HELP!!!

i followed the installation instructions but only worked on IOS, how were u able to get it work on Android. PLS HELP!!

ahmedelsayed11 commented 2 years ago

Please provide me with gradle.properties and Gradle wrapper version. And Android mainfest. And react native version. To help you ? @abazudosen

abazudosen commented 2 years ago
Screenshot 2022-07-02 at 07 26 30 AM Screenshot 2022-07-02 at 07 26 51 AM Screenshot 2022-07-02 at 07 27 16 AM

React Native version ==> 0.68.2

ahmedelsayed11 commented 2 years ago

First in gradle.wrapper.properties change distributionUrl to https\://services.gradle.org/distributions/gradle-6.9-all.zip And don't forger to request user permission in App.js or the app entry. And don't forget to add in android/buid.gradle maven { url 'https://api.mapbox.com/downloads/v2/releases/maven' authentication { basic(BasicAuthentication) } credentials { username = "mapbox" password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: "" } }

Wilfrid3 commented 7 months ago

Yes I have fixed the problem by check permission in android if simulate is false.

Where are you check permission? in APP.js? I need help please

SERCHAT commented 6 months ago

I have the same issue. I open android studio and check for that error is related with fusion location. I give the required permission ACCESS_FINE_LOCATION and enable it from app settings and then open the app and app crashes. Can anyone help us ? Thank you ....