안드로이드/에러 모음

Hilt 에러

김염인 2022. 8. 15. 22:41
Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? [Hilt] Processing did not complete. See error above for details.
error: [Hilt]
public final class MainActivity extends androidx.appcompat.app.AppCompatActivity implements [project].MainContract.View {
             ^
  Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
  See https://dagger.dev/hilt/gradle-setup.html
  [Hilt] Processing did not complete. See error above for details.

 

error: [Hilt]
public final class App extends android.app.Application {
             ^
  Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
  See https://dagger.dev/hilt/gradle-setup.html
  [Hilt] Processing did not complete. See error above for details.

 

위와 같이 에러가 발생하는 부분은 dagger 의 문제라기 보다는 kotlin 쪽 kapt 관련해서 생기는 문제이고, 아래의 방식으로 해결할 수 있다

 

1. kotlin version 을 낮춤 >> 1.5.20 에서 1.5.10 으로 낮추고 빌드해 보면 해당 에러가 사라지는 것을 볼 수 있다

2. kotlin version 을 높임 >> 1.5.20 에서 1.5.21 로 높이기만 해도 해당 에러가 사라지고 해결 된 것을 볼 수 있다

3. 1.5.20 으로 사용하고 싶다면 >> 아래 코드를 추가해서 annotation 쪽에 추가로 설정 시킬 수도 있다

kapt {
    javacOptions {
        option("-Adagger.fastInit=ENABLED")
        option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
    }
}