如何在Android应用中添加编译器参数?
我正在使用撰写,某些方法需要@optin(persuctiment -foundationapi :: class)
注释。
问题是,Android Studio在此注释中不断显示警告,并带有以下消息:应与编译器参数'-opt-in = kotlin.requiresoptin'一起使用此注释。
该代码正常工作,但我想做Android Studio建议删除此警告的事情。我该如何解决?
I'm using Compose and some methods require the @OptIn(ExperimentalFoundationApi::class)
annotation.
The thing is that the Android Studio keeps showing a warning in this annotation with the following message: This annotation should be used with the compiler argument '-opt-in=kotlin.RequiresOptIn'.
The code works normally but I would like to do what Android Studio suggests to remove this warning. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
build.gradle
中,您可以从应用模块中添加freecompilerargs +='-opt-in = kotlin.requiresoptin'
内部kotlinoptions
block。像这样:In the
build.gradle
from app module you can add thefreeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
insidekotlinOptions
block. Like this: