Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 996
Dario Scoppelletti Avatar asked Sep 12 '20 16:09

Dario Scoppelletti


Video Answer


1 Answers

android {
  kotlinOptions {
    freeCompilerArgs += '-Xexplicit-api=warning'
  }
}
like image 171
Pitel Avatar answered Sep 30 '22 14:09

Pitel