hotwired/turbo-android

TurboPathConfiguration.Location with unreachable `remoteFileUrl` crashes

HE-LU opened this issue · 2 comments

HE-LU commented

Hey,

we are extending TurboSessionNavHostFragment in our app, and we are overriding pathConfigurationLocation as follows.

override val pathConfigurationLocation: TurboPathConfiguration.Location = TurboPathConfiguration.Location(
    assetFilePath = "json/configuration.json",
    remoteFileUrl = ApiUtils.apiRouteSettings,
)

The issue occurs when the API host is for any reason unreachable, or the config is not found at the time, the app crashes when inflating MainActivity layout with the FragmentContainerView.

<androidx.fragment.app.FragmentContainerView
    android:id="@+id/mainNavHost"
    android:name="com.example.ui.SessionNavHostFragment" />

Important things from a LogCat:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.activities.MainActivity}: android.view.InflateException: Binary XML file line #47 in com.example:layout/activity_main: Binary XML file line #47 in com.example:layout/activity_main: Error inflating class androidx.fragment.app.FragmentContainerView

Caused by: android.view.InflateException: Binary XML file line #47 in com.example:layout/activity_main: Binary XML file line #47 in com.example:layout/activity_main: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #47 in com.example:layout/activity_main: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: java.lang.IllegalArgumentException: A start Fragment destination was not found for uri: turbo://fragment/web

I spent a full week until I realise this.
Thank you for opening this Issue.

Thanks for the report! Addressed in #305