android - 无法使用显式ApiWarning() 显示警告或错误
问题描述
我打算对我用 kotlin 制作的库使用explicitApiWarning。问题是我在 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'
}
}
推荐阅读
- vue.js - 使用 VueJS 为用户显示图像 EXIF
- python - 在 Windows 10 中将 Sybase 与 Python 连接起来
- r - 使用条件操作矩阵并连接结果
- python - sql.Identifier 不带引号
- c - 我想在使用写入功能时显示整数
- macos - 如何在终端中使用 IntelliJ 捆绑的 maven?
- android - 我有两个单选按钮,其中要执行单选。但是在单行上,两个单选按钮都被选中
- javascript - 防止 Next.js 生成某些路径文件
- ios - 使用 Apple ID 登录时显示无效的 responseType
- javascript - 如何从ajax布尔值中选择值