无法使用 explicitApiWarning() 显示警告或错误

Unable to show warning or errors with explicitApiWarning()

我打算为我的库使用 explicitApiWarning,它是用 kotlin 制作的。 问题是我在 build.gradle 文件中设置了以下脚本。不幸的是,它没有显示任何警告或错误。难道下面的标签应该放在特定的地方(比如在android {}之内)?还是需要一些特定的设置?根据文档,这看起来很简单,但我无法让它工作。除此之外,我想知道是否可以同时设置 explicitApiWarning 和 explicitApi?一些提示或示例会有所帮助。谢谢。

kotlin {
  explicitApiWarning()
}

https://kotlinlang.org/docs/reference/whatsnew14.html#explicit-api-mode-for-library-authors

    apply plugin: 'com.android.library'
    apply plugin: 'kotlin-android'

        
        android {
            compileSdkVersion 29
            buildToolsVersion "29.0.3"
        
            defaultConfig {
                minSdkVersion 24
                targetSdkVersion 29
                versionName "1.0"
        
                testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            }
        
      buildTypes {
        release {
          minifyEnabled false
        }
      }
    
      lintOptions {
        abortOnError true
      }
  }
        kotlin {
                explicitApiWarning()
        }

对于 android 库模块,设置显式 api 如下:

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