안드로이드 개발자들이 왜 Dagger에 관심을 가지고, 또 Dagger를 개발 모듈에 적용하고 싶어 하는지 하나씩 알아보고자 한다
Trouble Shooting
// appComponent lives in the Application class to share its lifecycle
class MyApplication : Application() {
// Reference to the application graph that is used across the whole app
var appComponent: ApplicationComponent = DaggerApplicationComponent.create()
}
Unresolved reference: DaggerApplicationComponent
위와 같은 에러가 발생한다면 먼저 build.gradle에 아래와 같이 추가를 부탁드립니다
(Dagger 버전은 원하시는 버전 쓰셔도 무방합니다)
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt' // Need to add this for using dagger
}
dependencies {
implementation 'com.google.dagger:dagger:2.12' // Need to add this for using dagger
kapt "com.google.dagger:dagger-compiler:2.12" // Need to add this for using dagger
그 후 Rebuild Project 한 번 해주시면 됩니다
Test app Git Hub 주소
'안드로이드 > 안드로이드 프레임워크' 카테고리의 다른 글
Android framework StartActivity 호출 순서 (0) | 2022.05.09 |
---|---|
StartActivity 호출 시 코드 진행 순서 3 (0) | 2022.04.30 |
StartActivity 호출 시 코드 진행 순서 2 (0) | 2022.04.29 |
StartActivity 호출 시 코드 진행 순서 1 (0) | 2022.04.24 |
안드로이드 4대 컴포넌트 (0) | 2022.04.10 |