6

My app has suddenly started crashing using the TimePickerDialog API. This is only happening on Google Pixel 6, 7, and 8's running Android 14. I see there was a security update March 4, 2024 and the crashes started on March 7, 2024 - maybe there's a connection? No other Android 14 device is affected and other Android versions are fine!

I have a Cordova app that uses the plugin https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.

Crashes occur when the user invokes the date and time picker, chooses the date (which is fine), but anything the user does with the time picker (hits the + or -, types in hour or minute and taps "next") causes a crash.

I looked in the Google issues tracker and don't see anything relevant: https://issuetracker.google.com/issues?q=status:open%20timepickerdialog

Here is a snippet of the code the plugin is using (written a few years ago):

 final TimePickerDialog timeDialog = new TimePickerDialog(currentCtx, theme, timeSetListener, jsonDate.hour,
        jsonDate.minutes, jsonDate.is24Hour) {
        public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            timePicker = view;
            timePickerHour = hourOfDay;
            timePickerMinute = minute;
        }
    };

Here is the crash log

 Exception 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
   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.validateInputTextView (NumberPicker.java:2030)
   at android.widget.NumberPicker.-$$Nest$mvalidateInputTextView
   at android.widget.NumberPicker$3.onFocusChange (NumberPicker.java:769)
   at android.view.View.onFocusChanged (View.java:8411)
   at android.widget.TextView.onFocusChanged (TextView.java:12813)
   at android.view.View.clearFocusInternal (View.java:8241)
   at android.view.View.clearFocus (View.java:8220)
   at android.view.ViewGroup.clearFocus (ViewGroup.java:1196)
   at android.view.ViewGroup.clearFocus (ViewGroup.java:1196)
   at android.view.ViewGroup.clearFocus (ViewGroup.java:1196)
   at android.view.ViewGroup.clearFocus (ViewGroup.java:1196)
   at android.app.TimePickerDialog$1.onClick (TimePickerDialog.java:159)
   at android.view.View.performClick (View.java:7729)
   at android.view.View.performClickInternal (View.java:7706)
   at android.view.View.-$$Nest$mperformClickInternal
   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
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:552)
   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:878)

Any help would be most appreciated!

Thanks, - Jon

1
  • The bug just made it into the most recent software update for Samsung Galaxy devices, so amount of crashes for users will climb up Commented Jun 17 at 6:03

3 Answers 3

0

I encountered essentially the same error on Android 14, so I switched to this: https://www.cssscript.com/mobile-ios-date-picker-rolldate/. I adapted the code to suit my preferences. Now, I have a more consistent UI between iOS and Android.

Sign up to request clarification or add additional context in comments.

Comments

0

You shall start using latest API TimePickerDialog.

Just replace your code to display picker dialog like below:

new TimePickerDialog(context, OnTimeSetListener, hourOfDay, minute, is24HourView);

If you need to set theme, add theme after the 'context' parameter above.

Comments

0

It's listed now under https://issuetracker.google.com/issues/333670354

My wife Pixel 7A doing this for a few weeks/month My Pixel 3XL is not having this issue

We are both using the same Lorex Cloud app version that use that timepicker

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.