6

I'm trying to include dagger hilt to my multimodule project with just three modules (app, frameworks_and_drivers, interface_adapters). I followed the hilt documentation https://developer.android.com/training/dependency-injection/hilt-android?hl=es-419, so i ended addding the same things to the three different modules, i know we can sinplify to just add in a single one. When i tried to rebuild the project this error appear: "error: cannot find symbol import dagger.hilt.android.components.ApplicationComponent;" enter image description here

for some reason the ApplicationComponent is not available even when the other are.

enter image description here

Maybe if one of you know how to fix this, please let me know. Thanks!

Oscar Ivan
  • 819
  • 1
  • 11
  • 21

2 Answers2

10

from 2.33-beta there is no ApplicationComponent, you will have to use SingletonComponent. docs is here.

CodeMonkey
  • 2,511
  • 4
  • 27
  • 38
sadat
  • 4,004
  • 2
  • 29
  • 49
5

I found a workaround updating the hilt version in build.gradle (Project) classpath 'com.google.dagger:hilt-android-gradle-plugin:2.31.2-alpha' and updating also the dependencies on build.gralde (your_module) **"

// DI with Hilt
    implementation "com.google.dagger:hilt-android:2.31.2-alpha"
    kapt "com.google.dagger:hilt-compiler:2.31.2-alpha"
    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03

'"** This is the video that helped to me with this: https://youtu.be/9ZnzmbClarw

Oscar Ivan
  • 819
  • 1
  • 11
  • 21
  • it worked for me after updating all dependencies version to latest version . update both `Project Gradle` and `Module Gradle` file. get latest version from here https://dagger.dev/hilt/gradle-setup.html – mhKarami Jul 13 '21 at 16:10