How can I set Kotlin compiler options in my Android Studio project, when I can't use Gradle?

Viewed 611

For a library I'm using, I get an error on some of the overridden methods:

Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option

The answer prior to my Bumblebee upgrade was to use kotlinOptions in the app build.gradle:

android {

    kotlinOptions {
        freeCompilerArgs = ['-Xjvm-default=compatibility']
        jvmTarget = "1.8"
    }

but now, kotlinOptions always breaks the build:

No signature of method: build_5rl9tbmrzydf364yqkdyvcpyq.android() is applicable for argument types: (build_5rl9tbmrzydf364yqkdyvcpyq$_run_closure1) values: [build_5rl9tbmrzydf364yqkdyvcpyq$_run_closure1@60f02a40]

so where else can I set the compiler options for Kotlin in Android Studio Bumblebee?

Or, how can I fix the build so that kotlinOptions works again?

1 Answers

The trick is to slow down and double check that you have all the requirements in your Gradle file for an Android Kotlin application. If you're missing version, or missing declaring dependencies, you're sure to get build errors. Once I checked off the boxes in the link here, everything built as it was supposed to.

In my case, I'm an iOS developer so a lot of 'fear of the unknown' was at work against me here. Once I just settled down and paid attention to giving my Gradle build the specifications it needed, I got more familiar and comfortable with the build system, and got the results I expected.

https://developer.android.com/kotlin/add-kotlin

Related