我有一个Fragment带有多个参数的构造函数.我的应用程序在开发期间工作正常,但在生产中我的用户有时会看到此崩溃:
android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment
make sure class name exists, is public, and has an empty constructor that is public
Run Code Online (Sandbox Code Playgroud)
我可以创建一个空的构造函数,因为这个错误消息建议,但这对我没有意义,因为那时我将不得不调用一个单独的方法来完成设置Fragment.
我很好奇为什么这种崩溃偶尔会发生.也许我使用ViewPager不正确?我Fragment自己实例化所有s并将它们保存在一个列表中Activity.我不使用FragmentManager事务,因为ViewPager我看到的例子并不需要它,并且一切似乎都在开发期间工作.