Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
Dagger 2 androidx fragment incompatible types

I'm using Dagger 2.21 and when I try to do

@Module
internal abstract class FragmentModule {
    @ContributesAndroidInjector
    internal abstract fun loginFragment() : LoginFragment
}

and

@Singleton
@Component(modules = [AndroidSupportInjectionModule::class, AppModule::class, ActivityModule::class, ViewModelBuilder::class, ViewModelModule::class, RepositoriesModule::class, ApiModule::class, FragmentModule::class])
interface AppComponent : AndroidInjector<PhotocoApplication> {
    @Component.Builder
    abstract class Builder : AndroidInjector.Builder<PhotocoApplication>()
}

I get this error:

/app/build/generated/source/kapt/debug/com/photoco/app/injection/module/FragmentModule_LoginFragment$app_debug.java:18: error: incompatible types: Class LoginFragment cannot be converted to Class extends Fragment

I have been searching and saw that using 2.21 and setting this gets it to work but no luck yet

android.useAndroidX=true ; android.enableJetifier=true

LoginFragment extends:

dagger.android.support.DaggerFragment()

With all this setup can't get it to build, am I missing something here? I can make it work with Activities using DaggerActivity but not with Fragments.

PhotocoApplication extends dagger.android.support.DaggerApplication

Thanks!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Fixed this issue by updating all dagger dependencies to 2.21, was missing android-support (was still using 2.16).

implementation 'com.google.dagger:dagger:2.21'
implementation 'com.google.dagger:dagger-android:2.21'
implementation 'com.google.dagger:dagger-android-support:2.21'
kapt "com.google.dagger:dagger-compiler:2.21"
kapt "com.google.dagger:dagger-android-processor:2.21"
over 4 years ago · Santiago Trujillo Denunciar

0

I just had the same problem but with two non-Android classes: EventBus and a wrapper class around Android resources.

I tried the solution proposed by Emanuel Amiguinho even it had nothing to do with android-support and it got fixed. So I tried to remove the added dependency and retry, and magically built successfully again.

So I guess in my case it was some caching issue.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda