I've just got a crash report from one of the users with the following error trace :
Unable to instantiate fragment packageName.Wizard$WizardFirstPage: make sure class name exists, is public, and has an empty constructor that is public
Here are the classes declarations :
public class Wizard extends Other
public abstract class Other extends BaseActivity
public abstract class BaseActivity extends ActionBarActivity
All classes are public, named and doesn't have user defined constructor.
As for the fragment WizardFirstPage
: (defined in Wizard
)
public class WizardFirstPage extends Fragment
No user defined constructor either.
What am I missing ?
public class WizardFirstPage extends Fragment
That is an inner class of packageName.Wizard
. That will only work if the class is declared as static
, as indicated by Blackbelt:
public static class WizardFirstPage extends Fragment
When the Wizard
activity undergoes a configuration change, or is re-created after process termination, Android is going to try to create an instance of Wizard$WizardFirstPage
. With your current approach, Android cannot do this, as only instances of Wizard
can create instances of Wizard$WizardFirstPage
. Changing WizardFirstPage
to be static
will fix this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With