mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
622 stars 319 forks source link

Mapbox Navigation Crashes on clicking Start Navigation #931

Closed Krageek closed 6 years ago

Krageek commented 6 years ago

This is my MapBoxNavigationActivity.java file

package com.example.kranthikiran.virtualtourguide;

import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

// classes needed to initialize map
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapView;

// classes needed to add location layer
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;

import android.location.Location;

import com.mapbox.mapboxsdk.geometry.LatLng;

import android.support.annotation.NonNull;

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerMode;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.services.android.location.LostLocationEngine;
import com.mapbox.services.android.navigation.ui.v5.NavigationLauncherOptions;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
import com.mapbox.services.android.telemetry.permissions.PermissionsListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;

// classes needed to add a marker
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;

// classes to calculate a route
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;
import com.mapbox.services.android.navigation.v5.navigation.NavigationRoute;
import com.mapbox.api.directions.v5.models.DirectionsResponse;
import com.mapbox.api.directions.v5.models.DirectionsRoute;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import android.util.Log;

// classes needed to launch navigation UI
import android.view.View;
import android.widget.Button;

import com.mapbox.services.android.navigation.ui.v5.NavigationLauncher;

// classes needed to add location layer
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;

import android.location.Location;

import com.mapbox.mapboxsdk.geometry.LatLng;

import android.support.annotation.NonNull;

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerMode;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.services.android.location.LostLocationEngine;
import com.mapbox.services.android.navigation.ui.v5.NavigationLauncherOptions;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
import com.mapbox.services.android.telemetry.permissions.PermissionsListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;

// classes needed to add a marker
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;

// classes to calculate a route
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;
import com.mapbox.services.android.navigation.v5.navigation.NavigationRoute;
import com.mapbox.api.directions.v5.models.DirectionsResponse;
import com.mapbox.api.directions.v5.models.DirectionsRoute;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import android.util.Log;

// classes needed to launch navigation UI
import android.view.View;
import android.widget.Button;

import com.mapbox.services.android.navigation.ui.v5.NavigationLauncher;

public class MapBoxNavigationActivity extends AppCompatActivity implements LocationEngineListener, PermissionsListener {

    private MapView mapView;

    // variables for adding location layer
    private MapboxMap map;
    private PermissionsManager permissionsManager;
    private LocationLayerPlugin locationPlugin;
    private LocationEngine locationEngine;
    private Location originLocation;

    // variables for adding a marker
    private Marker destinationMarker;
    private LatLng originCoord;
    private LatLng destinationCoord;

    // variables for calculating and drawing a route
    private Point originPosition;
    private Point destinationPosition;
    private DirectionsRoute currentRoute;
    private static final String TAG = "DirectionsActivity";
    private NavigationMapRoute navigationMapRoute;

    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Mapbox.getInstance(this, new String("pk.eyJ1Ijoia3JhZ3VpZGUiLCJhIjoiY2pndGVxZ3A3MDZkeDJxcGU0cHhzMzNsdCJ9.gC0nCJseWfIYSSgorprH6w"));
        setContentView(R.layout.activity_map_box_navigation);
        mapView = (MapView) findViewById(R.id.mapView);
        mapView.onCreate(savedInstanceState);

        mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(final MapboxMap mapboxMap) {

                map = mapboxMap;
                enableLocationPlugin();

                originCoord = new LatLng(originLocation.getLatitude(), originLocation.getLongitude());
                mapboxMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {
                    @Override
                    public void onMapClick(@NonNull LatLng point) {
                        if (destinationMarker != null) {
                            mapboxMap.removeMarker(destinationMarker);
                        }
                        destinationCoord = point;
                        destinationMarker = mapboxMap.addMarker(new MarkerOptions()
                                .position(destinationCoord)
                        );

                        destinationPosition = Point.fromLngLat(destinationCoord.getLongitude(), destinationCoord.getLatitude());
                        originPosition = Point.fromLngLat(originCoord.getLongitude(), originCoord.getLatitude());
                        getRoute(originPosition, destinationPosition);

                        button.setEnabled(true);
                        button.setBackgroundResource(R.color.mapboxBlue);

                    }

                    ;
                });

                button = findViewById(R.id.startButton);
                button.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        Point origin = originPosition;
                        Point destination = destinationPosition;
                        // Pass in your Amazon Polly pool id for speech synthesis using Amazon Polly
                        // Set to null to use the default Android speech synthesizer
                        String awsPoolId = null;
                        boolean simulateRoute = true;
                        NavigationLauncherOptions options = NavigationLauncherOptions.builder()
                                .origin(origin)
                                .destination(destination)
                                .awsPoolId(awsPoolId)
                                .shouldSimulateRoute(simulateRoute)
                                .build();

                        // Call this method with Context from within an Activity
                        NavigationLauncher.startNavigation(MapBoxNavigationActivity.this, options);
                    }
                });

            }

            ;
        });

    }

    private void getRoute(Point origin, Point destination) {
        NavigationRoute.builder()
                .accessToken(Mapbox.getAccessToken())
                .origin(origin)
                .destination(destination)
                .build()
                .getRoute(new Callback<DirectionsResponse>() {
                    @Override
                    public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
                        // You can get the generic HTTP info about the response
                        Log.d(TAG, "Response code: " + response.code());
                        if (response.body() == null) {
                            Log.e(TAG, "No routes found, make sure you set the right user and access token.");
                            return;
                        } else if (response.body().routes().size() < 1) {
                            Log.e(TAG, "No routes found");
                            return;
                        }

                        currentRoute = response.body().routes().get(0);

                        // Draw the route on the map
                        if (navigationMapRoute != null) {
                            navigationMapRoute.removeRoute();
                        } else {
                            navigationMapRoute = new NavigationMapRoute(null, mapView, map, R.style.NavigationMapRoute);
                        }
                        navigationMapRoute.addRoute(currentRoute);
                    }

                    @Override
                    public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
                        Log.e(TAG, "Error: " + throwable.getMessage());
                    }
                });
    }

    @SuppressWarnings( {"MissingPermission"})
    private void enableLocationPlugin() {
        // Check if permissions are enabled and if not request
        if (PermissionsManager.areLocationPermissionsGranted(this)) {
            // Create an instance of LOST location engine
            initializeLocationEngine();

            locationPlugin = new LocationLayerPlugin(mapView, map, locationEngine);
            locationPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);
        } else {
            permissionsManager = new PermissionsManager(this);
            permissionsManager.requestLocationPermissions(this);
        }
    }

    @SuppressWarnings( {"MissingPermission"})
    private void initializeLocationEngine() {
        locationEngine = new LostLocationEngine(MapBoxNavigationActivity.this);
        locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
        locationEngine.activate();

        Location lastLocation = locationEngine.getLastLocation();
        if (lastLocation != null) {
            originLocation = lastLocation;
            setCameraPosition(lastLocation);
        } else {
            locationEngine.addLocationEngineListener(this);
        }
    }

    private void setCameraPosition(Location location) {
        map.animateCamera(CameraUpdateFactory.newLatLngZoom(
                new LatLng(location.getLatitude(), location.getLongitude()), 13));
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    @Override
    public void onExplanationNeeded(List<String> permissionsToExplain) {

    }

    @Override
    public void onPermissionResult(boolean granted) {
        if (granted) {
            enableLocationPlugin();
        } else {
            finish();
        }
    }

    @Override
    @SuppressWarnings( {"MissingPermission"})
    public void onConnected() {
        locationEngine.requestLocationUpdates();
    }

    @Override
    public void onLocationChanged(Location location) {
        if (location != null) {
            originLocation = location;
            setCameraPosition(location);
            locationEngine.removeLocationEngineListener(this);
        }
    }

    @Override
    @SuppressWarnings( {"MissingPermission"})
    protected void onStart() {
        super.onStart();
        if (locationEngine != null) {
            locationEngine.requestLocationUpdates();
        }
        if (locationPlugin != null) {
            locationPlugin.onStart();
        }
        mapView.onStart();
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (locationEngine != null) {
            locationEngine.removeLocationUpdates();
        }
        if (locationPlugin != null) {
            locationPlugin.onStop();
        }
        mapView.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
        if (locationEngine != null) {
            locationEngine.deactivate();
        }
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        mapView.onLowMemory();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mapView.onPause();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }

    public void onBackPressed()
    {
        startActivity(new Intent(this,Home.class));
    }

}

This is my app level build.gradle file

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.kranthikiran.virtualtourguide"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.2@aar') {
        transitive=true
    }
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.12.0'
    implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.12.0') {
        transitive = true
    }

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.android.support:cardview-v7:26.1.0'
   compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.2@aar')
            {
                transitive=true
            }
    compile group: 'com.mapbox.mapboxsdk', name: 'mapbox-android-services', version: '2.2.10'
    compile 'com.android.support:design:26.1.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.2'
    implementation 'com.mapzen.android:lost:3.0.2'
    compile ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.7.1-SNAPSHOT') {
        transitive = true
    }
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.4.0'

}

apply plugin: 'com.google.gms.google-services'

This is the error that im getting

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.kranthikiran.virtualtourguide, PID: 1893
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kranthikiran.virtualtourguide/com.mapbox.services.android.navigation.ui.v5.NavigationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.services.android.navigation.ui.v5.NavigationView.onCreate(android.os.Bundle)' on a null object reference
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:148)
                      at android.app.ActivityThread.main(ActivityThread.java:5417)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.services.android.navigation.ui.v5.NavigationView.onCreate(android.os.Bundle)' on a null object reference
                      at com.mapbox.services.android.navigation.ui.v5.NavigationActivity.onCreate(NavigationActivity.java:39)
                      at android.app.Activity.performCreate(Activity.java:6251)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:148) 
                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

This is the code for the xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mapbox="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.mapbox.services.android.navigation.ui.v5.NavigationView
        android:id="@+id/navigationView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

    />

    <!--<com.mapbox.mapboxsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        mapbox:mapbox_cameraTargetLat="23.606371"
        mapbox:mapbox_cameraTargetLng="58.538971"
        mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10"
        mapbox:mapbox_cameraZoom="11" />-->

    <Button
        android:id="@+id/startButton"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:padding="5px"
        android:layout_margin="20px"
        android:text="Start navigation"
        android:background="@color/mapboxGrayLight"
        android:textColor="@color/mapboxWhite"
        android:enabled="false"/>

</RelativeLayout>
Meerz commented 6 years ago

@Krageek i also face this issue you can also use custom navigation activity like `@Override public void onNavigationReady() { NavigationViewOptions options = NavigationViewOptions.builder() .origin(origin) .destination(destination) .awsPoolId(awsPoolId) .shouldSimulateRoute(simulateRoute) .build();

navigationView.startNavigation(options); }`

your error will be resolved

Krageek commented 6 years ago

@Meerz Could you tell me where in the code do i add this?

danesfeder commented 6 years ago

Hey @Krageek, I'm seeing in your code that you're using NavigationView as well as NavigationLauncher - only one or the other should be used and I would also advise against using NavigationView in the same XML as a normal MapView. This is because NavigationView wraps a MapView and may cause conflicts with your normal MapView implementation.

In the future, please direct these types of questions to https://stackoverflow.com/questions/tagged/mapbox. This will help other developers see your issue and provide help. We (at Mapbox) are also checking these questions and will provide help there regarding your implementation. Thanks!

shrutiWV commented 5 years ago

Hey !! i too got the error

11-17 19:20:15.441 30900-30900/com.makani E/AndroidRuntime: FATAL EXCEPTION: main Process: com.makani, PID: 30900 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.makani/com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31) at android.app.Activity.performCreate(Activity.java:6251) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6251)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:619) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6251)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class com.mapbox.services.android.navigation.ui.v5.RecenterButton at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.view.View.inflate(View.java:19790) at com.mapbox.services.android.navigation.ui.v5.NavigationView.initializeView(NavigationView.java:485) at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:101) at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:95) at java.lang.reflect.Constructor.newInstance(Native Method)  at android.view.LayoutInflater.createView(LayoutInflater.java:619)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6251)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class com.mapbox.services.android.navigation.ui.v5.RecenterButton at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.view.View.inflate(View.java:19790)  at com.mapbox.services.android.navigation.ui.v5.NavigationView.initializeView(NavigationView.java:485)  at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:101)  at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:95)  at java.lang.reflect.Constructor.newInstance(Native Method)  at android.view.LayoutInflater.createView(LayoutInflater.java:619)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6251)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: java.lang.reflect.InvocationTa

while running the below code

NavigationLauncherOptions.Builder optionsBuilder = NavigationLauncherOptions.builder() .shouldSimulateRoute(false) .directionsProfile("driving-traffic"); optionsBuilder.directionsRoute(route); NavigationLauncher.startNavigation(this, optionsBuilder.build());

please help!!

Jamali-MohammadReza commented 5 years ago

i have same problem too `private void launchNavigationWithRoute() { if (route == null) { Snackbar.make(mapView, R.string.error_route_not_available, Snackbar.LENGTH_SHORT).show(); return; }

NavigationLauncherOptions.Builder optionsBuilder = NavigationLauncherOptions.builder()
  .shouldSimulateRoute(getShouldSimulateRouteFromSharedPreferences())
  .directionsProfile(getRouteProfileFromSharedPreferences());
optionsBuilder.directionsRoute(route);
NavigationLauncher.startNavigation(this, optionsBuilder.build());

}

in this function that implement from your sample repository and full code below package app.activities;

import android.content.Intent; import android.content.SharedPreferences; import android.location.Location; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.Toast;

import com.mapbox.android.core.location.LocationEngine; import com.mapbox.android.core.location.LocationEngineListener; import com.mapbox.android.core.location.LocationEngineProvider; import com.mapbox.api.directions.v5.DirectionsCriteria; import com.mapbox.api.directions.v5.models.DirectionsResponse; import com.mapbox.api.directions.v5.models.DirectionsRoute; import com.mapbox.core.constants.Constants; import com.mapbox.geojson.LineString; import com.mapbox.geojson.Point; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.location.LocationComponent; import com.mapbox.mapboxsdk.location.modes.RenderMode; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.services.android.navigation.ui.v5.NavigationLauncher; import com.mapbox.services.android.navigation.ui.v5.NavigationLauncherOptions; import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute; import com.mapbox.services.android.navigation.ui.v5.route.OnRouteSelectionChangeListener; import com.mapbox.services.android.navigation.v5.navigation.NavigationRoute; import com.mapbox.services.android.navigation.v5.utils.LocaleUtils;

import java.util.ArrayList; import java.util.List; import java.util.Locale;

import app.ir.kiantechno.bet.R; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import retrofit2.Call; import retrofit2.Response;

import static com.mapbox.android.core.location.LocationEnginePriority.HIGH_ACCURACY;

public class WorkBookActivity extends AppCompatActivity implements OnMapReadyCallback, MapboxMap.OnMapLongClickListener, LocationEngineListener, OnRouteSelectionChangeListener {

private static final int CAMERA_ANIMATION_DURATION = 1000; private static final int DEFAULT_CAMERA_ZOOM = 16; private static final int CHANGE_SETTING_REQUEST_CODE = 1; private static final int INITIAL_ZOOM = 16;

private LocationEngine locationEngine; private NavigationMapRoute mapRoute; private MapboxMap mapboxMap; private Marker currentMarker; private Point currentLocation; private Point destination; private DirectionsRoute route; private LocaleUtils localeUtils; private boolean locationFound;

@BindView(R.id.mapView) MapView mapView; @BindView(R.id.launch_route_btn) Button launchRouteBtn; @BindView(R.id.loading) ProgressBar loading; @BindView(R.id.launch_btn_frame) FrameLayout launchBtnFrame;

@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Mapbox.getInstance(this, getString(R.string.mapbox_access_token)); setContentView(R.layout.activity_work_book); ButterKnife.bind(this); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); localeUtils = new LocaleUtils(); }

@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.navigation_view_activity_menu, menu); return true; }

@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings: showSettings(); return true; default: return super.onOptionsItemSelected(item); } }

private void showSettings() { startActivityForResult(new Intent(this, NavigationSettingsActivity.class), CHANGE_SETTING_REQUEST_CODE); }

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CHANGE_SETTING_REQUEST_CODE && resultCode == RESULT_OK) { boolean shouldRefetch = data.getBooleanExtra(NavigationSettingsActivity.UNIT_TYPE_CHANGED, false) || data.getBooleanExtra(NavigationSettingsActivity.LANGUAGE_CHANGED, false); if (destination != null && shouldRefetch) { fetchRoute(); } } }

@Override protected void onStart() { super.onStart(); mapView.onStart(); }

@SuppressWarnings( {"MissingPermission"}) @Override public void onResume() { super.onResume(); mapView.onResume(); if (locationEngine != null) { locationEngine.addLocationEngineListener(this); if (!locationEngine.isConnected()) { locationEngine.activate(); } } }

@Override public void onPause() { super.onPause(); mapView.onPause(); if (locationEngine != null) { locationEngine.removeLocationEngineListener(this); } }

@Override public void onLowMemory() { super.onLowMemory(); mapView.onLowMemory(); }

@Override protected void onStop() { super.onStop(); mapView.onStop(); }

@Override protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); if (locationEngine != null) { locationEngine.removeLocationUpdates(); locationEngine.deactivate(); } }

@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); }

@OnClick(R.id.launch_route_btn) public void onRouteLaunchClick() { launchNavigationWithRoute(); }

@Override public void onMapReady(MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; this.mapboxMap.addOnMapLongClickListener(this); initLocationEngine(); initializeLocationComponent(); initMapRoute(); }

@Override public void onMapLongClick(@NonNull LatLng point) { destination = Point.fromLngLat(point.getLongitude(), point.getLatitude()); launchRouteBtn.setEnabled(false); loading.setVisibility(View.VISIBLE); setCurrentMarkerPosition(point); if (currentLocation != null) { fetchRoute(); } }

@SuppressWarnings( {"MissingPermission"}) @Override public void onConnected() { locationEngine.requestLocationUpdates(); }

@Override public void onLocationChanged(Location location) { currentLocation = Point.fromLngLat(location.getLongitude(), location.getLatitude()); onLocationFound(location); }

@Override public void onNewPrimaryRouteSelected(DirectionsRoute directionsRoute) { route = directionsRoute; }

@SuppressWarnings( {"MissingPermission"}) private void initLocationEngine() { locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable(); locationEngine.setPriority(HIGH_ACCURACY); locationEngine.setInterval(0); locationEngine.setFastestInterval(1000); locationEngine.addLocationEngineListener(this); locationEngine.activate();

if (locationEngine.getLastLocation() != null) {
  Location lastLocation = locationEngine.getLastLocation();
  onLocationChanged(lastLocation);
  currentLocation = Point.fromLngLat(lastLocation.getLongitude(), lastLocation.getLatitude());
}

}

@SuppressWarnings( {"MissingPermission"}) private void initializeLocationComponent() { LocationComponent locationComponent = mapboxMap.getLocationComponent(); locationComponent.activateLocationComponent(this, locationEngine); locationComponent.setLocationComponentEnabled(true); locationComponent.setRenderMode(RenderMode.COMPASS); }

private void initMapRoute() { mapRoute = new NavigationMapRoute(mapView, mapboxMap); mapRoute.setOnRouteSelectionChangeListener(this); }

private void fetchRoute() { NavigationRoute.Builder builder = NavigationRoute.builder(this) .accessToken(Mapbox.getAccessToken()) .origin(currentLocation) .destination(destination) .alternatives(true); setFieldsFromSharedPreferences(builder); builder.build() .getRoute(new SimplifiedCallback() { @Override public void onResponse(Call call, Response response) { if (validRouteResponse(response)) { hideLoading(); route = response.body().routes().get(0); if (route.distance() > 25d) { launchRouteBtn.setEnabled(true); mapRoute.addRoutes(response.body().routes()); boundCameraToRoute(); } else { Snackbar.make(mapView, R.string.error_select_longer_route, Snackbar.LENGTH_SHORT).show(); } } } }); loading.setVisibility(View.VISIBLE); }

private void setFieldsFromSharedPreferences(NavigationRoute.Builder builder) { builder .language(getLanguageFromSharedPreferences()) .voiceUnits(getUnitTypeFromSharedPreferences()); }

private String getUnitTypeFromSharedPreferences() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String defaultUnitType = getString(R.string.default_unit_type); String unitType = sharedPreferences.getString(getString(R.string.unit_type_key), defaultUnitType); if (unitType.equals(defaultUnitType)) { unitType = localeUtils.getUnitTypeForDeviceLocale(this); }

return unitType;

}

private Locale getLanguageFromSharedPreferences() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String defaultLanguage = getString(R.string.default_locale); String language = sharedPreferences.getString(getString(R.string.language_key), defaultLanguage); if (language.equals(defaultLanguage)) { return localeUtils.inferDeviceLocale(this); } else { return new Locale(language); } }

private boolean getShouldSimulateRouteFromSharedPreferences() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); return sharedPreferences.getBoolean(getString(R.string.simulate_route_key), false); }

private String getRouteProfileFromSharedPreferences() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); return sharedPreferences.getString( getString(R.string.route_profile_key), DirectionsCriteria.PROFILE_DRIVING_TRAFFIC ); }

private void launchNavigationWithRoute() { if (route == null) { Snackbar.make(mapView, R.string.error_route_not_available, Snackbar.LENGTH_SHORT).show(); return; }

NavigationLauncherOptions.Builder optionsBuilder = NavigationLauncherOptions.builder()
  .shouldSimulateRoute(getShouldSimulateRouteFromSharedPreferences())
  .directionsProfile(getRouteProfileFromSharedPreferences());
optionsBuilder.directionsRoute(route);
NavigationLauncher.startNavigation(this, optionsBuilder.build());

}

private boolean validRouteResponse(Response response) { return response.body() != null && !response.body().routes().isEmpty(); }

private void hideLoading() { if (loading.getVisibility() == View.VISIBLE) { loading.setVisibility(View.INVISIBLE); } }

private void onLocationFound(Location location) { if (!locationFound) { animateCamera(new LatLng(location.getLatitude(), location.getLongitude())); Snackbar.make(mapView, R.string.explanation_long_press_waypoint, Snackbar.LENGTH_LONG).show(); locationFound = true; hideLoading(); } }

public void boundCameraToRoute() { if (route != null) { List routeCoords = LineString.fromPolyline(route.geometry(), Constants.PRECISION_6).coordinates(); List bboxPoints = new ArrayList<>(); for (Point point : routeCoords) { bboxPoints.add(new LatLng(point.latitude(), point.longitude())); } if (bboxPoints.size() > 1) { try { LatLngBounds bounds = new LatLngBounds.Builder().includes(bboxPoints).build(); // left, top, right, bottom int topPadding = launchBtnFrame.getHeight() * 2; animateCameraBbox(bounds, CAMERA_ANIMATION_DURATION, new int[] {50, topPadding, 50, 100}); } catch (InvalidLatLngBoundsException exception) { Toast.makeText(this, R.string.error_valid_route_not_found, Toast.LENGTH_SHORT).show(); } } } }

private void animateCameraBbox(LatLngBounds bounds, int animationTime, int[] padding) { CameraPosition position = mapboxMap.getCameraForLatLngBounds(bounds, padding); mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), animationTime); }

private void animateCamera(LatLng point) { mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_CAMERA_ZOOM), CAMERA_ANIMATION_DURATION); }

private void setCurrentMarkerPosition(LatLng position) { if (position != null) { if (currentMarker == null) { MarkerViewOptions markerViewOptions = new MarkerViewOptions() .position(position); currentMarker = mapboxMap.addMarker(markerViewOptions); } else { currentMarker.setPosition(position); } } } } and my gradle below apply plugin: 'com.android.application'

android {

sourceSets {
    main {
        assets.srcDirs = ['src/main/assets', 'src/main/assets/']
        res.srcDirs = ['src/main/res', 'src/main/res/drawable']
    }
}
dexOptions {
    maxProcessCount 8
    javaMaxHeapSize "2g"
    preDexLibraries true
}
lintOptions {
    checkReleaseBuilds false
}
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
    applicationId 'app.com.kiantechno.bet'
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName '1.0.0'

// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { }

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies { annotationProcessor 'com.mindorks.android:placeholderview-compiler:1.0.3' implementation fileTree(include: ['*.jar'], dir: 'libs') //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:27.1.1' //noinspection GradleCompatible implementation 'com.android.support:design:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' //noinspection GradleCompatible implementation 'com.android.support:cardview-v7:26.0.1' implementation 'com.github.roojin:persian-calendar-view:1.2.2' implementation 'com.mcxiaoke.volley:library:1.0.19' implementation 'de.hdodenhof:circleimageview:2.+' implementation 'com.zarinpal:purchase:0.0.4-beta' implementation 'com.github.bumptech.glide:glide:3.7.0' implementation 'uk.co.chrisjenx:calligraphy:2.3.0' implementation 'com.github.markushi:circlebutton:1.1' implementation 'io.github.jeancsanchez.jcplayer:jcplayer:2.6.0-alpha' implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0' implementation 'com.mindorks.android:placeholderview:1.0.3' implementation 'com.google.code.gson:gson:2.8.0' implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.1.0' implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.7.1' implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.19.0' implementation "com.jakewharton:butterknife:8.8.1" implementation "com.jakewharton:butterknife-compiler:8.8.1" annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

} and add maven { url 'https://mapbox.bintray.com/mapbox' } to gradle and get this error: 12-03 01:12:28.276 24297-24297/app.com.kiantechno.bet E/AndroidRuntime: FATAL EXCEPTION: main Process: app.com.kiantechno.bet, PID: 24297 java.lang.RuntimeException: Unable to start activity ComponentInfo{app.com.kiantechno.bet/com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) at android.app.ActivityThread.access$900(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5951) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView at android.view.LayoutInflater.createView(LayoutInflater.java:640) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at android.view.LayoutInflater.inflate(LayoutInflater.java:366) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5951)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:614) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)  at android.view.LayoutInflater.inflate(LayoutInflater.java:511)  at android.view.LayoutInflater.inflate(LayoutInflater.java:415)  at android.view.LayoutInflater.inflate(LayoutInflater.java:366)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6289)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5951)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)  Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class com.mapbox.services.android.navigation.ui.v5.RecenterButton at android.view.LayoutInflater.createView(LayoutInflater.java:640) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at android.view.LayoutInflater.inflate(LayoutInflater.java:366) at android.view.View.inflate(View.java:19574) at com.mapbox.services.android.navigation.ui.v5.NavigationView.initializeView(NavigationView.java:419) at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:96) at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:90) at java.lang.reflect.Constructor.newInstance(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:288)  at android.view.LayoutInflater.createView(LayoutInflater.java:614)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)  at android.view.LayoutInflater.inflate(LayoutInflater.java:511)  at android.view.LayoutInflater.inflate(LayoutInflater.java:415)  at android.view.LayoutInflater.inflate(LayoutInflater.java:366)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6289)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5951)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:614) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)  at android.view.LayoutInflater.inflate(LayoutInflater.java:511)  at android.view.LayoutInflater.inflate(LayoutInflater.java:415)  at android.view.LayoutInflater.inflate(LayoutInflater.java:366)  at android.view.View.inflate(View.java:19574)  at com.mapbox.services.android.navigation.ui.v5.NavigationView.initializeView(NavigationView.java:419)  at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:96)  at com.mapbox.services.android.navigation.ui.v5.NavigationView.(NavigationView.java:90)  at java.lang.reflect.Constructor.newInstance(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:288)  at android.view.LayoutInflater.createView(LayoutInflater.java:614)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)  at android.view.LayoutInflater.inflate(LayoutInflater.java:511)  at android.view.LayoutInflater.inflate(LayoutInflater.java:415)  at android.view.LayoutInflater.inflate(LayoutInflater.java:366)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.mapbox.services.android.navigation.ui.v5.MapboxNavigationActivity.onCreate(MapboxNavigationActivity.java:31)  at android.app.Activity.performCreate(Activity.java:6289)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5951)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)  Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class TextView at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.rInflate(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at android.vie` please help