https://kotlinlang.org logo
#getting-started
Title
# getting-started
n

Nick

11/29/2021, 9:29 PM
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

ephemient

11/29/2021, 10:00 PM
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

Joffrey

11/30/2021, 12:09 AM
Warnings in the IDE normally respect the gradle config
e

ephemient

11/30/2021, 2:17 AM
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

Nick

11/30/2021, 4:31 AM
I think you’re right @ephemient, I’m not seeing the warnings in the output from Gradle. It’s so annoying 😕
n

Nick

11/30/2021, 4:41 AM
eeek so it is known already.
j

Joffrey

11/30/2021, 7:56 AM
@ephemient probably an Android Studio specific issue then, because in IDEA it has always worked fine for me
e

ephemient

11/30/2021, 11:32 AM
@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

Joffrey

11/30/2021, 11:35 AM
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.
46 Views