hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
408 stars 51 forks source link

TurboPathConfiguration.Location with unreachable `remoteFileUrl` crashes #271

Closed HE-LU closed 5 months ago

HE-LU commented 1 year ago

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
diegocharles commented 1 year ago

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

jayohms commented 5 months ago

Thanks for the report! Addressed in #305