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?
>Solution :
In the build.gradle from app module you can add the freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn' inside kotlinOptions block. Like this:
plugins {
// ...
}
android {
// ...
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
}
// ...
}
dependencies {
// ...
}