Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin Opt-in: Flag is not supported by this version of the compiler

Tags:

android

kotlin

I followed the Kotlin documentation here and here to opt into kotlin.ExperimentalUnsignedTypes for the whole module. My module build.gradle looks like this now:

android {

    ...

    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += "-Xopt-in=kotlin.ExperimentalUnsignedTypes"
    }

Lint is still complaining about ExperimentalUnsignedTypes and when compiling I get this warning:

> Task :myModule:compileDebugKotlin
w: Flag is not supported by this version of the compiler: -Xopt-in=kotlin.ExperimentalUnsignedTypes

My kotlin version is: 1.3.61

like image 372
A1m Avatar asked Oct 21 '25 10:10

A1m


1 Answers

As mentioned in the docs here

@RequireOptIn and @OptIn annotations were introduced in 1.3.70 to replace previously used @Experimental and @UseExperimental; at the same time, -Xopt-in compiler option replaced -Xuse-experimental.

@OptIn(...::class) and use of -Xopt-in=... were introduced in Kotlin 1.3.70, but the old and gold -Xuse-experimental is still available in future versions (tested in Kotlin 1.4-M1).

like image 197
Animesh Sahu Avatar answered Oct 23 '25 01:10

Animesh Sahu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!