eucalypto / time-tracker

Android Time Tracker App that uses NFC Tags.
MIT License
0 stars 0 forks source link

App crashes when editing an activity time on screen rotation #21

Closed eucalypto closed 3 years ago

eucalypto commented 3 years ago

With the following stack trace

Process: net.eucalypto.timetracker, PID: 30954
    java.lang.RuntimeException: Unable to start activity
ComponentInfo{net.eucalypto.timetracker/net.eucalypto.timetracker.MainActivity}:
androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment
net.eucalypto.timetracker.activities.TimePickerFragment: could not find Fragment constructor
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3271)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)

[...]

Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment
net.eucalypto.timetracker.activities.TimePickerFragment: could not find Fragment constructor
        at androidx.fragment.app.Fragment.instantiate(Fragment.java:628)
        at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
eucalypto commented 3 years ago

According to this: https://stackoverflow.com/questions/51831053/could-not-find-fragment-constructor

I need a no-arg public constructor for my DialogFragment so that it can be re-constructed on config change.

The proposed solutions are a) use an arguments Bundle, or b) usa a viewModel (maybe shared between main fragment and DialogFragment.