Hi I am trying to add OptIn in my compiler gradle....
# android
k
Hi I am trying to add OptIn in my compiler gradle.
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        freeCompilerArgs += [
            "-Xuse-experimental=com.google.accompanist.permissions.ExperimentalPermissionsApi"
        ]
    }
}
I tried this piece of code but it giving me error. Can anyone guide me what I am doing wrong here
Screenshot 2022-09-16 at 14.33.18.png
Copy code
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        kotlin_version = '1.6.10'
        accompanist_version = "0.23.1"
    }

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url '<https://mobile-sdk.jumio.com>' }
        maven { url '<https://jitpack.io>' }
    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            freeCompilerArgs += [
                "-Xuse-experimental=com.google.accompanist.permissions.ExperimentalPermissionsApi"
            ]
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
c
you still need to apply the
OptIn
annotation to the class or function thats invoking the experimental API
k
okk
So no other way to remove in every class OptIn?
j
I remember getting this to work as described, but it's been too long ago that I could tell you what's wrong here. But as I said, iirc, it's worth it to keep looking.
c
i think maybe your syntax is a little wrong. Try this:
Copy code
"-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi"
k
Perfect It works.. @Ciaran Sloan Thanks
🤘 2