I need to use method setStartTimestamp(OffsetDateTime startTimestamp)
but my minSdk is 21 so it shows me Call requires API level 26
. Is there any way how can I use OffsetDateTime on lower apis?
You can use Java 8+ API desugaring support (Android Gradle Plugin 4.0.0+)
It is described in this link
Simply you have to modify your build.gradle file in your app module like this:
android {
defaultConfig {
// Required when setting minSdkVersion to 20 or lower
multiDexEnabled true
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
}
java.time
APIs on Android require API 26.
For older API levels you can use ThreeTenABP which is the Android version of JSR-310 java.time
backport for Java 6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With