How to ignore the “avoid non-default constructors in fragments” error?

后端 未结 4 968
执笔经年
执笔经年 2021-02-03 23:23

I got this error while trying to generate the signed APK. The thing is, my app is able to run and debug normally on my device. I don\'t know why when I try to generate APK, this

4条回答
  •  面向向阳花
    2021-02-03 23:47

    It is in the Fragment's contract: "Every fragment must have an empty constructor, so it can be instantiated when restoring its activity's state. It is strongly recommended that subclasses do not have other constructors with parameters, since these constructors will not be called when the fragment is re-instantiated; instead, arguments can be supplied by the caller with setArguments(Bundle) and later retrieved by the Fragment with getArguments()."

提交回复
热议问题