Android-API级别21中的日期
你好,我对Android还是有点陌生 目前,我对本地日期或我尝试过的任何其他日期格式有一个很大的问题Android-API级别21中的日期,android,api,date,Android,Api,Date,你好,我对Android还是有点陌生 目前,我对本地日期或我尝试过的任何其他日期格式有一个很大的问题 LocalDate currentDate = LocalDate().now(); 此行产生以下错误: Call requires API Level 26 (current min is 21) 我完全理解这意味着什么,但我不能改变项目的API级别,因为我与我的老师签订了一份合同,我和一位合作伙伴将按照我们计划的方式完成我们的学校项目 如何使用API级别为21的任何类型的日期 格拉德尔:
LocalDate currentDate = LocalDate().now();
此行产生以下错误:
Call requires API Level 26 (current min is 21)
我完全理解这意味着什么,但我不能改变项目的API级别,因为我与我的老师签订了一份合同,我和一位合作伙伴将按照我们计划的方式完成我们的学校项目
如何使用API级别为21的任何类型的日期
格拉德尔:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.fragment"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "0.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
android {
compileOptions {
coreLibraryDesugaringEnabled true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:19.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'me.dm7.barcodescanner:zxing:1.9'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:22.0.0'
implementation 'com.google.code.gson:gson:2.8.6'
}
将此添加到build.gradle文件:
android {
compileOptions {
coreLibraryDesugaringEnabled true
}
}
从4.0开始的Android Gradle插件的较新版本能够使用desugaring将新API向后移植到较旧版本的Android。您可以在此处阅读更多信息:
请注意,您必须使用Android Studio的Beta版才能访问这些功能:将其添加到build.gradle文件中:
android {
compileOptions {
coreLibraryDesugaringEnabled true
}
}
从4.0开始的Android Gradle插件的较新版本能够使用desugaring将新API向后移植到较旧版本的Android。您可以在此处阅读更多信息:
请注意,您必须使用Android Studio的Beta版才能访问这些功能:我与其他人在一个团队中工作,他们中的每个人现在都需要这个Beta版吗?我相信是的。另一个选择是使用流行的库。这不是Java 8版本的库,但API基本上是完全相同的。谢谢,我把它标记为正确的anwser,我想我会尝试ThreeTenABP,因为如果我说团队中的其他人必须安装不同的版本,他们会杀了我。谢谢Ben PI和其他人一起在团队中工作他们每个人现在都需要这个测试版吗?我相信是的。另一个选择是使用流行的库。这不是Java 8版本的库,但API基本上是完全相同的。谢谢,我把它标记为正确的anwser,我想我会尝试ThreeTenABP,因为如果我说团队中的其他人必须安装不同的版本,他们会杀了我。谢谢你,Ben,回答你的问题?或者,这回答了你的问题吗?还是?