Like the title states, I get the below exception when trying to change the value of the TimePicker via tapping the '+' or '-' button. Started getting this a after a few clients started to complained to me. Was only able to replicate it once I updated to the very latest version of Android from my Pixel 8 Pro (Build # AP1A.240305.019.A1, Android Version 14, Android Security Update 3/5/2024). Did not experience this with a build immediately before this one.
I commented out every piece of code. Just simply adding a TimePicker to the layout and tapping the button replicates the issues (no need to get a handle, modify or attach to handlers).
FATAL EXCEPTION: main Process: com.police.nycmoneymanagement, PID: 32232 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.EditText.hasFocus()' on a null object reference at android.widget.TimePickerSpinnerDelegate.updateInputState(TimePickerSpinnerDelegate.java:480) at android.widget.TimePickerSpinnerDelegate.-$$Nest$mupdateInputState(Unknown Source:0) at android.widget.TimePickerSpinnerDelegate$2.onValueChange(TimePickerSpinnerDelegate.java:119) at android.widget.NumberPicker.notifyChange(NumberPicker.java:2080) at android.widget.NumberPicker.setValueInternal(NumberPicker.java:1850) at android.widget.NumberPicker.changeValueByOne(NumberPicker.java:1879) at android.widget.NumberPicker.-$$Nest$mchangeValueByOne(Unknown Source:0) at android.widget.NumberPicker$1.onClick(NumberPicker.java:723) at android.view.View.performClick(View.java:7729) at android.view.View.performClickInternal(View.java:7706) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:30484) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8501) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
I have just encountered the same issue on a Pixel 6 with Android 14 build AP1A.240405.002 Security patch 5th April 2024
It's reproducible with a TimePickerDialog which uses a custom theme such as:
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), R.style.my_time_picker_dialog_theme, this, startHr, startMin, true);
<style name="my_time_picker_dialog_theme" parent="ThemeOverlay.AppCompat.Dialog">
<item name="colorAccent">#ff000000</item> <!--header background-->
<item name="android:windowBackground">#ff000000</item> <!--calendar background-->
But the crash doesn't occur when using a standard theme such as:
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), AlertDialog.THEME_HOLO_DARK, this, startHr, startMin, true);
// options: THEME_TRADITIONAL THEME_DEVICE_DEFAULT_LIGHT THEME_DEVICE_DEFAULT_DARK THEME_HOLO_LIGHT THEME_HOLO_DARK
(Just to rule out a couple of recent library updates: 01-05-24 Updated implementation 'com.google.android.gms:play-services-maps:18.2.0' from 18.1.0 01-05-24 Updated implementation 'androidx.preference:preference:1.2.1' from 1.2.0 I reverted them, but the crash remains, so it's nothing to do with those)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With