mapbox / mapbox-navigation-android

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

NavigationView crashes on RecenterButton #2301

Closed zimiole closed 4 years ago

zimiole commented 4 years ago

Device: Samsung J3, Vodaphone VFD900 Android API: v5.1.1 (Samsung), v6.01 (VFD900) Mapbox Navigation SDK version: 0.42.0 and 0.42.4

Steps to trigger behavior

  1. Add a com.mapbox.services.android.navigation.ui.v5.NavigationView to the Android's Fragment <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="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="match_parent"
        android:layout_height="match_parent" />
  2. Inflate layout

    class SupportNavigationFragment : DaggerFragment(), OnNavigationReadyCallback, NavigationListener, ProgressChangeListener, SpeechAnnouncementListener {

    companion object {
        val TAG: String = SupportNavigationFragment::class.java.simpleName
    
        fun newInstance(
            directionRoute: DirectionsRoute?,
            startLocation: Location?
        ): SupportNavigationFragment {
            val fragment = SupportNavigationFragment()
            val arguments = Bundle()
            arguments.putParcelable(ARG_START_LOCATION, startLocation)
            arguments.putSerializable(ARG_DIRECTION_ROUTE, directionRoute)
            fragment.arguments = arguments
            return fragment
        }
    }
    
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_support_navigation, container, false)
    }
    
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
    
        navigationView.onCreate(savedInstanceState)
        ...
        val position = CameraPosition.Builder()
            .target(initialLocation)
            .zoom(NAV_ZOOM)
            .tilt(NAV_TILT)
            .build()
    
        navigationView.initialize(this, position)
    }
  3. Crash

Expected behavior

The application shows NavigaitonView without a crash

Actual behavior

The applicaiton crashes with logs:

android.view.InflateException: Binary XML file line #7: 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 com.*.SupportNavigationFragment.onCreateView(SupportNavigationFragment.kt:59) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) android.view.InflateException: Binary XML file line #7: 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 com.*.SupportNavigationFragment.onCreateView(SupportNavigationFragment.kt:59) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663) at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613 at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904) at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerIm at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6934) 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:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) aused 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) ... 31 more Caused by: android.view.InflateException: Binary XML file line #30: 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:19920) at com.mapbox.services.android.navigation.ui.v5.NavigationView.initializeView(NavigationView.java:510) at com.mapbox.services.android.navigation.ui.v5.NavigationView.<init>(NavigationView.java:106) at com.mapbox.services.android.navigation.ui.v5.NavigationView.<init>(NavigationView.java:100) ... 34 more

Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class com.mapbox.services.android.navigation.ui.v5.RecenterButton

oddlymagical commented 4 years ago

Thanks for the details. I believe this may be due to the layout, though I would need to see the larger context of the code to be sure.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="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="match_parent"
    android:layout_height="match_parent" />

Have you looked at our example of a NavigationView with Fragment? The link only shows the java code, you'll also want to look at the layout xml. When adding a fragment, we use ConstraintLayout instead of Framelayout.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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/navigation_view_fragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navigationDarkTheme="@style/NavigationViewDark"
        app:navigationLightTheme="@style/NavigationViewLight"/>

</androidx.constraintlayout.widget.ConstraintLayout>

If you still get the error after trying ConstraintLayout, please share an example project that displays the behavior, so I can recreate the error and do some troubleshooting.

Thanks, Brandi

zimiole commented 4 years ago

@brandihaskins I've changed to ConstraintLayout but it made no change. Full code:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navigationDarkTheme="@style/NavigationTheme"
        app:navigationLightTheme="@style/NavigationTheme" />

</androidx.constraintlayout.widget.ConstraintLayout>
<style name="NavigationTheme" parent="@style/NavigationViewLight">
        <!-- The main turn banner view at the top of the screen -->
        <!-- Background color of the banner -->
        <item name="navigationViewBannerBackground">@color/jobLayoutBackgroundColor</item>
        <!-- Color for the primary label that displays the turn name -->
        <item name="navigationViewBannerPrimaryText">?attr/jetColor</item>
        <!-- Color for the secondary label that occasionally appears underneath the primary label -->
        <item name="navigationViewBannerSecondaryText">?attr/jetColor</item>
        <!-- Primary color for the turn arrow icons-->
        <item name="navigationViewBannerManeuverPrimary">?attr/jetColor</item>
        <!-- Secondary color for the turn arrow icons (e.g. the line segment that forks off) -->
        <item name="navigationViewBannerManeuverSecondary">?attr/jetColor</item>
        <!-- Color for the main duration label in the summary view -->
        <item name="navigationViewPrimaryText">?attr/jetColor</item>
        <!-- Color for the secondary distance and ETA label in the summary view -->
        <item name="navigationViewSecondaryText">?attr/jetColor</item>
    </style>
import android.location.Location
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.testapp.app.R
import com.mapbox.api.directions.v5.models.DirectionsRoute
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.services.android.navigation.ui.v5.NavigationViewOptions
import com.mapbox.services.android.navigation.ui.v5.OnNavigationReadyCallback
import com.mapbox.services.android.navigation.ui.v5.camera.DynamicCamera
import com.mapbox.services.android.navigation.ui.v5.listeners.NavigationListener
import com.mapbox.services.android.navigation.ui.v5.listeners.SpeechAnnouncementListener
import com.mapbox.services.android.navigation.ui.v5.voice.SpeechAnnouncement
import com.mapbox.services.android.navigation.v5.navigation.camera.RouteInformation
import com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress
import dagger.android.support.DaggerFragment
import kotlinx.android.synthetic.main.fragment_support_navigation.*

private const val DEFAULT_LATITUDE = 0.0
private const val DEFAULT_LONGITUDE = 0.0
private const val ARG_DIRECTION_ROUTE = "ARG_DIRECTION_ROUTE"
private const val ARG_START_LOCATION = "ARG_START_LOCATION"
private const val NAV_ZOOM = 14.5
private const val NAV_TILT = 30.0

class SupportNavigationFragment : DaggerFragment(), OnNavigationReadyCallback, NavigationListener,
    ProgressChangeListener, SpeechAnnouncementListener {

    companion object {
        val TAG: String = SupportNavigationFragment::class.java.simpleName

        fun newInstance(
            directionRoute: DirectionsRoute?,
            startLocation: Location?
        ): SupportNavigationFragment {
            val fragment = SupportNavigationFragment()
            val arguments = Bundle()
            arguments.putParcelable(ARG_START_LOCATION, startLocation)
            arguments.putSerializable(ARG_DIRECTION_ROUTE, directionRoute)
            fragment.arguments = arguments
            return fragment
        }
    }

    private var shouldUseSpeech: Boolean = false
    private var currentRoute: DirectionsRoute? = null
    private var isNavigationReady = false

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_support_navigation, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        navigationView.onCreate(savedInstanceState)
        val initialLocation =
            if (arguments?.getParcelable(ARG_START_LOCATION) as? Location != null) {
                LatLng(arguments?.getParcelable(ARG_START_LOCATION) as? Location)
            } else {
                LatLng(DEFAULT_LATITUDE, DEFAULT_LONGITUDE)
            }

        val position = CameraPosition.Builder()
            .target(initialLocation)
            .zoom(NAV_ZOOM)
            .tilt(NAV_TILT)
            .build()

        navigationView.initialize(this, position)
    }

    override fun onStart() {
        super.onStart()
        navigationView.onStart()
    }

    override fun onResume() {
        super.onResume()
        navigationView.onResume()
    }

    override fun onSaveInstanceState(outState: Bundle) {
        navigationView.onSaveInstanceState(outState)
        outState.putSerializable(ARG_DIRECTION_ROUTE, currentRoute)
        super.onSaveInstanceState(outState)
    }

    override fun onViewStateRestored(savedInstanceState: Bundle?) {
        super.onViewStateRestored(savedInstanceState)
        savedInstanceState?.let {
            currentRoute = it.getSerializable(ARG_DIRECTION_ROUTE) as? DirectionsRoute
            navigationView.onRestoreInstanceState(it)
        }
    }

    override fun onPause() {
        super.onPause()
        navigationView.onPause()
    }

    override fun onStop() {
        super.onStop()
        navigationView.onStop()
    }

    override fun onLowMemory() {
        super.onLowMemory()
        navigationView.onLowMemory()
    }

    override fun onDestroyView() {
        super.onDestroyView()
        navigationView.onDestroy()
    }

    override fun onNavigationReady(isRunning: Boolean) {
        isNavigationReady = true
        currentRoute?.also {
            startNavigation(it)
        }
    }

    override fun willVoice(announcement: SpeechAnnouncement?): SpeechAnnouncement? {
        return if (shouldUseSpeech) {
            announcement
        } else {
            null
        }
    }

    override fun onCancelNavigation() {
        navigationView.stopNavigation()
    }

    override fun onNavigationFinished() {
        // NOP
    }

    override fun onNavigationRunning() {
        // NOP
    }

    override fun onProgressChange(location: Location?, routeProgress: RouteProgress?) {
        // NOP
    }

    fun shouldUseSpeech(doUseSpeech: Boolean) {
        shouldUseSpeech = doUseSpeech
    }

    fun changeDirection(directionsRoute: DirectionsRoute) {
        currentRoute = directionsRoute
        if (isNavigationReady) {
            startNavigation(directionsRoute)
        } else {
            navigationView?.initialize(this)
        }
    }

    private fun startNavigation(directionsRoute: DirectionsRoute) {
        val options = NavigationViewOptions.builder()
            .directionsRoute(directionsRoute)
            .navigationListener(this)
            .progressChangeListener(this)
            .speechAnnouncementListener(this)
            .waynameChipEnabled(false)
            .build()

        // These views are only available once navigation has begun
        navigationView?.apply {
            startNavigation(options)
            retrieveAlertView().updateEnabled(false)
            retrieveSoundButton().hide()
            retrieveFeedbackButton().hide()
            hideRecenterBtn()
            updateWayNameVisibility(false)
            retrieveNavigationMapboxMap()?.apply {
                updateWaynameQueryMap(false)

                retrieveMap()?.also { map ->
                    map.uiSettings.apply {
                        isRotateGesturesEnabled = false
                        isTiltGesturesEnabled = false
                        isQuickZoomGesturesEnabled = false
                    }

                    retrieveMapboxNavigation()?.cameraEngine = object : DynamicCamera(map) {
                        override fun tilt(routeInformation: RouteInformation?): Double {
                            return NAV_TILT
                        }

                        override fun zoom(routeInformation: RouteInformation?): Double {
                            return NAV_ZOOM
                        }
                    }
                }
            }
        }
    }
}

Caused by: android.view.InflateException: Binary XML file line #30: Binary XML file line #30: Error inflating class com.mapbox.services.android.navigation.ui.v5.RecenterButton Error message:

    Process: com.testapp.app, PID: 8806
    android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView
        at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
        at com.testapp.app.ui.common.fragment.SupportNavigationFragment.onCreateView(SupportNavigationFragment.kt:59)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5438)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
     Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.mapbox.services.android.navigation.ui.v5.NavigationView
        at android.view.LayoutInflater.createView(LayoutInflater.java:649)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
        at com.testapp.app.ui.common.fragment.SupportNavigationFragment.onCreateView(SupportNavigationFragment.kt:59) 
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) 
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) 
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) 
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) 
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) 
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) 
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) 
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663) 
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613) 
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904) 
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100) 
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874) 
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830) 
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) 
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) 
        at android.os.Handler.handleCallback(Handler.java:739) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5438) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at android.view.LayoutInflater.createView(LayoutInflater.java:623)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:839) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:519) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
        at com.testapp.app.ui.common.fragment.SupportNavigationFragment.onCreateView(SupportNavigationFragment.kt:59) 
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) 
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) 
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) 
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) 
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) 
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) 
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) 
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663) 
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613) 
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904) 
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100) 
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874) 
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830) 
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) 
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) 
        at android.os.Handler.handleCallback(Handler.java:739) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5438) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
     Caused by: android.view.InflateException: Binary XML file line #30: Binary XML file line #30: Error inflating class com.mapbox.services.android.navigation.ui.v5.RecenterButton
        at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at android.view.View.inflate(View.java:19814)
        at com.mapbox.services.android.navigation.ui.v5.NavigationView.initializeView(NavigationView.java:510)
        at com.mapbox.services.android.navigation.ui.v5.NavigationView.<init>(NavigationView.java:106)
        at com.mapbox.services.android.navigation.ui.v5.NavigationView.<init>(NavigationView.ja
moritzzzzz commented 4 years ago

@zimiole Hi Oleh,

I took a look through your code and could not find where you define the style of the NavigationView.

You can do that in the layout XML file:

<com.mapbox.services.android.navigation.ui.v5.NavigationView
        android:id="@+id/navigationView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:navigationDarkTheme="@style/CustomNavigationView"
        app:navigationLightTheme="@style/CustomNavigationView"
        app:navigationViewMapStyle="<StyleURL>"/>

Please add your desired style URL in place of \. Let me know if you still receive the same error!

Kind regards, Moritz

zimiole commented 4 years ago

@moritzzzzz hi Moritz,

Can you provide an example of navigationViewMapStyle which is desired? I cannot find such a declaration in Mapbox examples or documentation. Also, such code works fine on other devices.

Thanks! Oleh

moritzzzzz commented 4 years ago

@zimiole please refer to this documentation on style URLs to get a valid style URL that you can use with the NavigationView.

If you like we can have a call to discuss this. Therefore, please provide me with your email address.

moritzzzzz commented 4 years ago

Summary of the screen sharing session:

I could not find obvious problems. Although using a custom NavigationView, the problem also occurs when using the non-modified com.mapbox.services.android.navigation.ui.v5.NavigationView in the layout.

The crash does not occur on emulated devices of API version 28 and 29. (it was mentioned that it does not crash on lower API versions of emulated devices). The application crashes when opening the NavigationView on specific physical devices. Not on all physical devices!

I have requested:

cc @zimiole @brandihaskins

moritzzzzz commented 4 years ago

To consolidate the information here:

Information from Oleh

I've created a quick solution for Mapbox team to check the crash. It's in mapbox_crash branch in our repository. You don't have to login, or anything else, just manually enable the Location Permission before starting the application. Then, click the Continue button - it will open a separate activity that holds a base fragment with our navigation. It doesn't crash on the emulator, but does crash on our test devices. The list of devices where we can reproduce the crash:

Samsung J3 with android v5.1.1 Vodafone VFD900 with Android 6.01 Vodafone VFD511 with Android 7.1.1 Xiaomi Mi 3 with Android 6.0.1 Let me know if you have any questions.

zimiole commented 4 years ago

@moritzzzzz please provide when we can expect this issue will be fixed?

moritzzzzz commented 4 years ago

@zimiole So far we were able to reproduce the issue also on emulated devices of API < 26. Our Android navigation team will discuss this issue in our sprint planning today. I will keep you posted on our progress.

moritzzzzz commented 4 years ago

@zimiole We have found a fix that solves the behaviour on our end. We will test it today and share it with you as soon as we are done testing.

moritzzzzz commented 4 years ago

@zimiole We have found a way to workaround the crash on lower versions of Android: <API 26. This is not a fix for the root cause, which appears to lie with themes you are using and seems to be related to: https://issuetracker.google.com/issues/140956412

We recommend that you check your code, to make sure it does not run into this issue.

In the meantime, could you please confirm that the navigation-ui SDK snapshot version we have created that removes the line

android:textAllCaps="true"

from its layout, solves the issue on your end?

These are the steps, you would have to follow to use the snapshot version, instead of the release version:

Add this line to root/build.gradle.kts as shown below in the screenshot

url = URI("https://oss.sonatype.org/content/repositories/snapshots/")

image

Change the dependency of mapboxAndroidNavigationVersion from 0.42.5 to 0.43.0-20200303.222201-238 in Dependencies.ktas shown in the screenshot below

image

This is a timestamped version which will expire. Please do the testing as soon as possible.

Also I would like to stress again, that we recommend that you check, if you are using material theming which is posing problems with AppCompatTextView in older devices.

Please let me know if you have questions, or if something is unclear!

zimiole commented 4 years ago

hey @moritzzzzz , I've checked the snapshot build on our device and it seems to work now.

moritzzzzz commented 4 years ago

@zimiole Great, good to hear!