[Compose 도입] 1. Compose를 도입해보자.

이승우·2023년 5월 14일
0

Android에서 Compose를 도입해보자. 여기서는 Compose에 대한 개념이 아닌 어떻게 도입할 수 있는지에 대해서만 간단하게 다뤄볼 예정이다.

1. Compose 설정

build.gradle에 아래와 같이 추가하면 된다.

android {
    buildFeatures {
        compose true
    }

    composeOptions {
        kotlinCompilerExtensionVersion = "1.4.2"
    }
}
  • buildFeatrues { } 내에서 compose true로 설정하면 Compose 기능이 사용 설정된다.
  • Composeoptions { } 내에 정의된 kotlin 컴파일러 확장 프로그램 버전 관리는 Kotlin 버전 관리에 연결된다.

그리고 이제는 Compose 라이브러리 종속 항목의 하위 의존성을 추가해보자.

// material design
implementation 'androidx.compose.material:material'

// such as input and measurement/layout
// 레이아웃이나 뷰를 그릴 때, 입력 등 기기와 상호작용할 때 필요한 요소
implementation 'androidx.compose.ui:ui'

// Android Studio Preview support
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'

// Optional - Integration with activities
implementation 'androidx.activity:activity-compose:1.6.1'
// Optional - Integration with ViewModels
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1'

Ref

profile
Android Developer

0개의 댓글