在尝试添加依赖项时出现gradle错误。我正在尝试使用Wdullaer的库,但收到错误消息:
清单合并失败:uses-sdk:minSdkVersion 15不能小于库[com.wdullaer:materialdatetimepicker:4.0.1]中声明的版本16 /home/jonathon/.gradle/caches/transforms-1/files-1.1 /materialdatetimepicker-4.0.1.aar/e6a687a3cda7a3733aea1e4617c99341/AndroidManifest.xml,因为该库可能使用了15中未提供的API 建议:使用兼容的库,其minSdk最多为15, 或将该项目的minSdk版本提高到至少16, 或使用tools:overrideLibrary =“ com.wdullaer.materialdatetimepicker”强制使用(可能导致运行时失败)
我试图更改minSdkVerison,但仍然出现某种错误。
成绩文件:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
debugCompile 'com.amitshekhar.android:debug-db:1.0.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
compile 'com.wdullaer:materialdatetimepicker:4.0.1'
}
https://github.com/wdullaer/MaterialDateTimePicker
如果由于某种原因无法使用,那么有人对日期和时间选择器库有某种建议吗?谢谢。
答案 0 :(得分:0)
使用此日期选择器方法可获得更好的性能。.它也支持在min设备中。希望它对您有用。
private void datePicker(){
// Get Current Date
final Calendar c = Calendar.getInstance();
final int mYear = c.get(Calendar.YEAR);
final int mMonth = c.get(Calendar.MONTH);
final int mDay = c.get(Calendar.DAY_OF_MONTH);
//get day Name
SimpleDateFormat sdfday = new SimpleDateFormat("EEEE");
Date d_name = new Date(mYear-1900,mMonth,mDay);
final String dayOfTheWeek = sdfday.format(d_name);
final DatePickerDialog datePickerDialog = new DatePickerDialog(this,R.style.picker1,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,int monthOfYear, int dayOfMonth) {
//get calendar format
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
final String formatedDate = sdf.format(new Date(year-1900, monthOfYear, dayOfMonth));
date_time = formatedDate;
//*************Call Time Picker Here ********************
}
}, mYear, mMonth, mDay);
datePickerDialog.getDatePicker().setMinDate(c.getTimeInMillis());
datePickerDialog.show();
}
private void timePicker(){
// Get Current Time
final Calendar c = Calendar.getInstance();
final int mHour = c.get(Calendar.HOUR_OF_DAY);
final int mMinute = c.get(Calendar.MINUTE);
// Launch Time Picker Dialog
TimePickerDialog timePickerDialog = new TimePickerDialog(this,R.style.picker1,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,int minute) {
DateInput.setText(date_time+" "+String.format("%02d:%02d", hourOfDay, minute));
Log.d("datenew",date_time + hourOfDay+":"+minute);
}
}, mHour, mMinute, false);
timePickerDialog.show();
}