Bigkoo/Android-PickerView · error · RuntimeException
type[] length is not 6
Error message
type[] length is not 6
What it means
WheelTime.setLunar throws an uncaught RuntimeException when the boolean[] type array configuring which wheels (year, month, day, hours, minutes, seconds) are visible does not have exactly 6 elements. The array is indexed element-by-element, so any other length is invalid.
Solutions
- Always pass a 6-element boolean[] in order year, month, day, hours, minutes, seconds
- Use the Builder's setType(boolean...) and pass all 6 flags, using false for wheels you want hidden
- Note this variant throws RuntimeException (not IllegalArgumentException) — don't rely on catching the declared type
Example fix
// before
timePicker.setType(new boolean[]{true, true, true}); // throws
// after
timePicker.setType(new boolean[]{true, true, true, false, false, false}); Defensive patterns
Strategy: validation
Validate before calling
static boolean isValidTypeArray(boolean[] type) {
return type != null && type.length == 6;
} Type guard
static boolean[] requireSixFlags(boolean[] type) {
if (type == null || type.length != 6)
throw new IllegalArgumentException("type must have 6 flags: year,month,day,hours,minutes,seconds");
return type;
} Try / catch
try {
wheelTime.setLunar(type);
} catch (RuntimeException e) {
wheelTime.setLunar(new boolean[]{true,true,true,true,true,true});
} Prevention
- Always build the type array with exactly 6 entries (year, month, day, hours, minutes, seconds)
- Use false, not a shorter array, to hide wheels
- Define a shared constant like ALL_SIX = {true,true,true,true,true,true}
When it happens
Trigger: Calling setLunar with a boolean[] shorter or longer than 6, e.g. new boolean[]{true,true,true} to show only y/m/d, or building the array dynamically with a variable count.
Common situations: Wanting to hide some units and assuming a shorter array means 'show only these'; copying a snippet with a 3- or 5-element array; refactoring the type array without updating all initializers.
Related errors
- startDate can't be later than endDate
- The startDate can not as early as 1900
- The endDate should not be later than 2100
- Illegal lunar date, must be like that: year …
AI-assisted analysis of Bigkoo/Android-PickerView@e200d8c063 (2026-09-07).
Data as JSON: /api/errors/a041f6837d4f3c71.
Report an issue: GitHub.
Appendix: source
Thrown at pickerview/src/main/java/com/bigkoo/pickerview/view/WheelTime.java:219
}
if (currentIndex > maxItem - 1) {
wv_day.setCurrentItem(maxItem - 1);
}
if (mSelectChangeCallback != null) {
mSelectChangeCallback.onTimeSelectChanged();
}
}
});
setChangedListener(wv_day);
setChangedListener(wv_hours);
setChangedListener(wv_minutes);
setChangedListener(wv_seconds);
if (type.length != 6) {
throw new RuntimeException("type[] length is not 6");
}
wv_year.setVisibility(type[0] ? View.VISIBLE : View.GONE);
wv_month.setVisibility(type[1] ? View.VISIBLE : View.GONE);
wv_day.setVisibility(type[2] ? View.VISIBLE : View.GONE);
wv_hours.setVisibility(type[3] ? View.VISIBLE : View.GONE);
wv_minutes.setVisibility(type[4] ? View.VISIBLE : View.GONE);
wv_seconds.setVisibility(type[5] ? View.VISIBLE : View.GONE);
setContentTextSize();
}
/**
* 设置公历
*
* @param year
* @param month
* @param day
* @param h
* @param mView on GitHub (pinned to e200d8c063)