Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android java.lang.NoClassDefFoundError:java.time.format.DateTimeFormatter_Android - Fatal编程技术网

Android java.lang.NoClassDefFoundError:java.time.format.DateTimeFormatter

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

我正在尝试使用DateTimeFormatter格式化日期和时间。使用下面的代码

DateTimeFormatter dateFormat=DateTimeFormatter.of模式YYYY/MM/dd; dateFormat.formatLocalDateTime.now

但它不会抛出任何错误

我的gradle文件具有以下配置:

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'
    }
}
}

我不明白这里有什么不对。

如果你明白了,那就意味着这个类不存在


改用RelativeDateTimeFormatter

DateTimeFormatter是在API级别26中添加的,您有min 16。那么,在min sdk 16中使用它有什么诀窍吗,因为它已包含在java 8中。