Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add Compiler Argument in Android app?

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 {
    // ...
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading