I’m going crazy getting my `freeCompilerArgs` work...
# getting-started
n
I’m going crazy getting my
freeCompilerArgs
working. I’m still getting errors/warnings with what I have tried below. This is in the
build.gradle
of a module.
Copy code
android {
    kotlinOptions.freeCompilerArgs += compilerArgs
}
and
Copy code
tasks {
    withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
        kotlinOptions.freeCompilerArgs += compilerArgs
    }
}
…. more in thread 🧵
Copy code
val compilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn",
    "-Xopt-in=kotlinx.coroutines.FlowPreview",
    "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
    "-Xopt-in=com.google.accompanist.pager.ExperimentalPagerApi",
    "-Xopt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi",
    "-Xopt-in=coil.annotation.ExperimentalCoilApi",
    "-Xopt-in=androidx.compose.ui.unit.ExperimentalUnitApi",
    "-Xopt-in=androidx.compose.ui.ExperimentalComposeUiApi",
    "-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
    "-Xopt-in=androidx.compose.material.ExperimentalMaterialApi",
    "-Xopt-in=coil.annotation.ExperimentalCoilApi",

    "-Xjvm-default=all"
)
image.png
e
warnings in gradle or warnings in the ide? the former should be addressed by your gradle config, the latter I don't think you can do anything about (at least I haven't found any way)
j
Warnings in the IDE normally respect the gradle config
e
they're probably supposed to, but at least for me Android Studio has never picked up strict API mode or opt-in annotations from Gradle
n
I think you’re right @ephemient, I’m not seeing the warnings in the output from Gradle. It’s so annoying 😕
n
eeek so it is known already.
j
@ephemient probably an Android Studio specific issue then, because in IDEA it has always worked fine for me
e
@Joffrey probably multiple issues, note that one linked issue indicates that IDEA EAP is broken in addition to the other linked issue about all current versions of AS
j
Yes, sorry I was thinking about the opt-in compiler arguments (but I didn't write my message as such). Indeed the strict mode issue seems to also affect IDEA.