In Kotlin, i'm trying to define an Interface with only one method. When trying to the following code:
fun interface someInterFace
{
fun someFunc()
}
I'm getting the following error message: "expecting function name or receiver type" Can someone explain me what i'm doing wrong? I'm using it exactly as it described in: Functional (SAM) interfaces
You need to change the languageVersion of kotlin to 1.4 or above that. For that, you do not have to change the version of ext.kotlin_version to 1.4+, but You need to write just a few lines in build.gradle file:
kotlinOptions {
jvmTarget = '1.8'
languageVersion = "1.4"
}
You can now sync the gradle and your code will work now.
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