我的Android应用crashlytics已记录此错误:
androidx.fragment.app.Fragment.performSaveInstanceState
Fragment.java, line 3292
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.material.datepicker.Month com.google.android.material.datepicker.MaterialCalendar.getCurrentMonth()' on a null object
reference
com.google.android.material.datepicker.MaterialDatePicker.onSaveInstanceState MaterialDatePicker.java:154
androidx.fragment.app.Fragment.performSaveInstanceState Fragment.java:3292
androidx.fragment.app.FragmentStateManager.saveBasicState FragmentStateManager.java:681
androidx.fragment.app.FragmentStateManager.saveState FragmentStateManager.java:647
androidx.fragment.app.FragmentStore.saveActiveFragments FragmentStore.java:214
androidx.fragment.app.FragmentManager.saveAllStateInternal FragmentManager.java:2371
androidx.fragment.app.Fragment.performSaveInstanceState Fragment.java:3294
androidx.fragment.app.FragmentStateManager.saveBasicState FragmentStateManager.java:681
androidx.fragment.app.FragmentStateManager.saveState FragmentStateManager.java:647
androidx.fragment.app.FragmentStore.saveActiveFragments FragmentStore.java:214
androidx.fragment.app.FragmentManager.saveAllStateInternal FragmentManager.java:2371
androidx.fragment.app.Fragment.performSaveInstanceState Fragment.java:3294
androidx.fragment.app.FragmentStateManager.saveBasicState FragmentStateManager.java:681
androidx.fragment.app.FragmentStateManager.saveState FragmentStateManager.java:647
androidx.fragment.app.FragmentStore.saveActiveFragments FragmentStore.java:214
androidx.fragment.app.FragmentManager.saveAllStateInternal FragmentManager.java:2371
字符串
这种情况并不总是发生,但大多数受影响的操作系统是在11,12和13,大多数是在三星Galaxy设备
我目前正在使用
implementation 'com.google.android.material:material:1.4.0'
型
你知不知道该怎么避免这种事?
1条答案
按热度按时间axr492tv1#
你可以使用材料库获取当前月份使用以下代码。
字符串