In some cases, you can have more than one build.gradle file.
One way uou can quickly find them is by doing a universal search for "compileOptions" and seeing the results and in which places.
If the problem still persists, you will need to make this change matching CompileOptions and KotlinOptions (as described above) in the other ones. Typically the error will mention the module. enter image description here This was my scenario.