TargetCompatibility and SourceCompatibility

Hello!

I have a question about the common in all my project old as hell gradle script:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

I will remind you in case you already deleted it many years ago, it is a part of app/build.gradle file and it is inside Android block.

Can you help me to understand if I can delete it from the gradle?
I am asking myself:
since all my project is written on Kotlin,
since Kotlin is so common in Android development and Google officially support Kotlin as primary language,
since Java …12? or higher is already released and gradle 7.0.0 requires at least Java 11 to run,

do I really need these compatibility options in build.gradle?

Thank you for any help!

Neither of those options are tied to the JDK that you use to build the module. They control the code generated by the build process. Newer JDK versions can emit bytecode for older JVMs.

I do not know, sorry. I have not tried removing them from a module where I had them previously.

I used a dirty way to check… Created a new project in Android Studio and in the build.gradle file there are still those lines of script. Probably, I need to keep them.

I thought there is an explanation somewhere why they are still required