material-components / material-components/material-components-android
[com.google.android.material.datepicker;e] RangeDateSelector issue
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:** On some devices, I encounter a crash with stack trace here:
`androidx.core.util.Preconditions.checkArgument Preconditions.java:38
com.google.android.material.datepicker.RangeDateSelector.setSelection RangeDateSelector.java:84
com.google.android.material.datepicker.RangeDateSelector.setSelection RangeDateSelector.java:51
com.google.android.material.datepicker.MaterialDatePicker$Builder.build MaterialDatePicker.java:627`
**Expected behavior:** This should not crash.
**Source code:**
```
@Override
public void setSelection(@NonNull Pair selection) {
if (selection.first != null && selection.second != null) {
Preconditions.checkArgument(isValidRange(selection.first, selection.second));
}
selectedStartItem =
selection.first == null ? null : UtcDates.canonicalYearMonthDay(selection.first);
selectedEndItem =
selection.second == null ? null : UtcDates.canonicalYearMonthDay(selection.second);
}
```
Happens when isValidRange == false which shouldnt happen
**Android API version:** 13 and 12
**Material Library version:** Material Android Library version you are using here (e.g., 1.1.0-alpha07) com.google.android.material:material:1.4.0
**Device:** Samsung s20 FE 5G, Samsung S21 FE 5g ,Galaxy S10e
To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.
We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stack trace in RangeDateSelector.java, especially setSelection and the isValidRange check reached while MaterialDatePicker.Builder.build runs. Reproduce on the listed Samsung devices or Android 12/13, then determine why an invalid range reaches this path; done means the reported date-picker flow no longer crashes and the behavior is covered by an appropriate regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100