Error: Avoid non-default constructors in fragments

#1

I’m getting an error when building for android, and although the build completes, the whole app crashes whenever I try to load it.
Help!

#2

It works fine on iOS btw

#3
[stderr] /src/exponent/android-shell-app/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/AlertFragment.java:39: Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]
[stderr]   public AlertFragment(@Nullable DialogModule.AlertFragmentListener listener, Bundle arguments) {
[stderr]          ~~~~~~~~~~~~~
[stderr] /src/exponent/android-shell-app/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/SupportAlertFragment.java:32: Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]
[stderr]   public SupportAlertFragment(@Nullable DialogModule.AlertFragmentListener listener, Bundle arguments) {
[stderr]          ~~~~~~~~~~~~~~~~~~~~
[stderr]    Explanation for issues of type "ValidFragment":
[stderr]    From the Fragment documentation:
[stderr]    Every fragment must have an empty constructor, so it can be instantiated
[stderr]    when restoring its activity's state. It is strongly recommended that
[stderr]    subclasses do not have other constructors with parameters, since these
[stderr]    constructors will not be called when the fragment is re-instantiated;
[stderr]    instead, arguments can be supplied by the caller with setArguments(Bundle)
[stderr]    and later retrieved by the Fragment with getArguments().
[stderr]    http://developer.android.com/reference/android/app/Fragment.html#Fragment()
[stderr] 2 errors, 0 warnings
closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.