Using Hilt but the base project is using Dagger

43 views Asked by At

I want to use Hilt with the @AndroidEntryPoint annotation in MyActivity, but I have to create classes by extending BaseActivity from a first-party library, which appears to use a different dependency injection tool. (Dagger, I reckon)

MyActivity.kt

@AndroidEntryPoint // if I do not use Hilt, there is no error.
class MyActivity : BaseActivity() { 
   @Inject
   lateinit var something: Something
}

BaseActivity.java

public class BaseActivity extends AppCompatActivity {
   @Inject
   protected Logger log; // this causes the error.
}

I have got an error like

/package/HiltComponents error:[Dagger/MissingBinding] *Logger* cannot be provided without an @Inject constructor or an @Provides-annotated method 
Missing binding usage: *Logger* is injected at ... MyActivity is injected at injectMyActivity ... 

Is it possible to use Dagger and Hilt together in this way?

FYI, I have no auth to access the first-library code.

0

There are 0 answers