Android java.lang.NoClassDefFoundError:java.time.format.DateTimeFormatter
我正在尝试使用DateTimeFormatter格式化日期和时间。使用下面的代码 DateTimeFormatter dateFormat=DateTimeFormatter.of模式YYYY/MM/dd; dateFormat.formatLocalDateTime.now 但它不会抛出任何错误 我的gradle文件具有以下配置:Android java.lang.NoClassDefFoundError:java.time.format.DateTimeFormatter,android,Android,我正在尝试使用DateTimeFormatter格式化日期和时间。使用下面的代码 DateTimeFormatter dateFormat=DateTimeFormatter.of模式YYYY/MM/dd; dateFormat.formatLocalDateTime.now 但它不会抛出任何错误 我的gradle文件具有以下配置: android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { appl
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
我不明白这里有什么不对。如果你明白了,那就意味着这个类不存在
改用RelativeDateTimeFormatterDateTimeFormatter是在API级别26中添加的,您有min 16。那么,在min sdk 16中使用它有什么诀窍吗,因为它已包含在java 8中。