I have a simple fragment as shown below.
class GradesFragment : Fragment(R.layout.fragment_grades) {
...
companion object {
@JvmStatic
fun newInstance() = GradesFragment()
}
}
I added this fragment to MainActivity as the following.
class MainActivity : AppCompatActivity(R.layout.activity_main) {
supportFragmentManager.beginTransaction()
.replace(R.id.frameLayout, GradesFragment.newInstance())
.addToBackStack("tagMainFragment")
.commit()
}
When I tested my app in prod and debug, there is no crash. However, my app crashes in prod users, firebase crashlytics shows many errors. No specific device or no specific version. Many android versions and devices faces this crash.
It shows the following error: androidx.fragment.app.Fragment$d: Unable to instantiate fragment com.xxx.yyy.d.b: could not find Fragment constructor
To be able to use fragment and activity constructor, should I add somethings to proguard file? What am I missing? Why some users faces crash but some other user do not face crash ?