[Android] 기존프로젝트에서 Jetpack Compose 사용

minnie·2022년 9월 1일
0

Jetpack

목록 보기
13/13
post-thumbnail

1. 개발 환경 설정

  • Jetpack Compose로 최적의 환경에서 개발하려면 Android 스튜디오 버전에 맞는 Android Gradle 플러그인을 구성해야 합니다.
    build.gradle(project) 에서 해당 버전에 맞게 구성합니다.
buildscript {
    ...
    dependencies {
        classpath "com.android.tools.build:gradle:7.2.2"
        ...
    }
}
  • kotlin 구성
    build.gradle(app)에서 프로젝트에서 코틀린을 사용하는지 확인합니다.
plugins {
    id 'kotlin-android'
}
  • Gradle 구성
    앱의 최소 API 수준을 21 이상으로 설정하고 build.gradle(app)에서 Jetpack Compose를 사용 설정해야합니다. kotlin 컴파일러 플러그인의 버전도 설정해야합니다.
    buildFeatures {
        // Enables Jetpack Compose for this module
        compose true
    }
    
    composeOptions {
        kotlinCompilerExtensionVersion '1.3.0'
    }

2. Jetpack Compose 도구 키트 종속 항목 추가

build.gradle 파일에 Jetpack Compose 도구 키트 종속 항목을 포함해야합니다.

dependencies {
    // Integration with activities
    implementation 'androidx.activity:activity-compose:1.5.1'
    // Compose Material Design
    implementation 'androidx.compose.material:material:1.2.1'
    // Animations
    implementation 'androidx.compose.animation:animation:1.2.1'
    // Tooling support (Previews, etc.)
    implementation 'androidx.compose.ui:ui-tooling:1.2.1'
    // Integration with ViewModels
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1'
    // UI Tests
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.2.1'
}
profile
Android Developer

0개의 댓글