티스토리 뷰

[Android] This annotation should be used with the compiler argument '-opt-in=kotlin.RequiresOptIn' 해결하기

Jetpack Compose 사용하여 개발을 할 때 실험 적인 기능, 일부 베타 기능을 사용할 때 아래와 같은 어노테이션을 적용하여 사용하게 된다.

@OptIn(ExperimentalMaterial3Api::class)

위 어노테이션 적용 후 빌드, 컴파일은 문제 없이 잘 되지만, 경고가 발생하여 좀 거슬렸다. 이를 제거하기 위해 app 수준 build.gradle 에 아래와 같은 옵션을 추가해준다.

android {
    //...
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions {
            freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
        }
    }
    //...
}

이후 sync 를 해주고 다시 돌아가보면 경고가 사라진 것을 볼 수 있다. 🫣

2022.10.09 - [Android/Groovy] - [Android Groovy] build.gradle plugins apply false? 왜 false 인가

2022.09.30 - [Android/Retrofit] - [Android] Retrofit HTTP Converter 결과값 파싱이 null 로 올 때 ☠️

2022.08.23 - [SELECT *] - [Android] 해상도별 drawable 이미지 리소스 추가하기 (dpi 별)

댓글
최근에 올라온 글
최근에 달린 댓글
네이버 이웃추가
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함