https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
c

chrmelchior

01/23/2020, 11:05 AM
Anyone know how you set
kotlinOptions
(specifically
freeCompilerArgs
) for
android
targets? I must be missing something obvious, but
android.compilations
is just an empty array (which is also a bit weird and doesn’t match https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#default-project-layout) and using
Copy code
targets.all {
        compilations.all {
            kotlinOptions {
                freeCompilerArgs = ["..."]
            }
        }
    }
does not work either (which kinda makes sense since the compilations array is empty).
Looks like the Android targets are not available until after the evaluation phase. Doing it after seemed to do the trick:
Copy code
project.afterEvaluate {
    kotlin.targets.android.compilations.all {
        kotlinOptions {
            freeCompilerArgs = ["..."]
        }
    }
}
o

Oleg Yukhnevich

01/23/2020, 12:36 PM
+1, some time ago also found that issue...
k

Kris Wong

01/23/2020, 3:04 PM
this is what I use, but not sure if it addresses your issue specifically:
Copy code
tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
    kotlinOptions.freeCompilerArgs += "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi"
}
2 Views