I tried everything, but the error not getting solved
Here is my code:
public String[] getWeekDays() {
LocalDate today = LocalDate.now();
LocalDate monday = today;
LocalDate tue = today;
LocalDate wed = today;
LocalDate thur = today;
LocalDate fri = today;
LocalDate sat = today;
LocalDate sunday = today;
while (sunday.getDayOfWeek() != DayOfWeek.SUNDAY){
sunday = sunday.minusDays(1);
}
while (monday.getDayOfWeek() != DayOfWeek.MONDAY){
monday = monday.minusDays(1);
}
while (tue.getDayOfWeek() != DayOfWeek.TUESDAY){
tue = tue.plusDays(1);
}
while (wed.getDayOfWeek() != DayOfWeek.WEDNESDAY){
wed = wed.plusDays(1);
}
while (thur.getDayOfWeek() != DayOfWeek.THURSDAY){
thur = thur.plusDays(1);
}
while (fri.getDayOfWeek() != DayOfWeek.FRIDAY){
fri = fri.plusDays(1);
}
while (sat.getDayOfWeek() != DayOfWeek.SATURDAY){
sat = sat.plusDays(1);
}
String[] days = {String.valueOf(sunday),String.valueOf(monday), String.valueOf(tue), String.valueOf(wed),
String.valueOf(thur), String.valueOf(fri), String.valueOf(sat)};
return days;
}
I have written the code to get dates of one week. When I running this code, i am getting an error at LocalDate.now();. The error is "java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalDate;". I have searched on the net. Some are saying it requires API level min 27. I have tired on API 27 level but the error didn't get resolved. More ever my target device is API 26 I needed to run on this API level. And also tried adding "compile "java.time:LocalTime:1.8" ". This one also doesn't work. Please help me...