In my Android app
build.gradle
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
...
}
....
}
Kotlin code
val data = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Base64.getDecoder().decode(str)
} else {
Base64.decode(str, Base64.DEFAULT) // Unresolved reference: decode
}
Obviously, I got compilation error, when using Base64 variant prior to API 24.
But how can I support all the API levels and use Base64 as before 24, as after?