Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: cannot find symbol import dagger.hilt.android.components.ApplicationComponent;

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!

like image 907
Oscar Ivan Avatar asked Dec 09 '22 23:12

Oscar Ivan


2 Answers

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

like image 169
sadat Avatar answered Jan 11 '23 23:01

sadat


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

like image 45
Oscar Ivan Avatar answered Jan 11 '23 23:01

Oscar Ivan