How can I enable Explcit API mode in an Android/Kotlin library module?

Viewed 420

I use Android 4.0.1, and Kotlin 1.4.10. I tried to insert:

kotlin {
   explicitApi()
}

at the top level of the module build.gradle file, but Android Studio seems to ignore it.

I tried to insert the same block in the android { ... } block, but Android Studio seems to ignore it.

I tried to insert explicitApi() in android.kotlinOptions { ... } block, but the Gradle project sync failed.

1 Answers
android {
  kotlinOptions {
    freeCompilerArgs += '-Xexplicit-api=warning'
  }
}
Related