Search code examples
androiddagger-2dagger

What is the difference between dagger.android.support.DaggerApplication and dagger.android.DaggerApplication?


When I was experimenting with Dagger2.22 I found similar classes dagger.android.support.DaggerApplication and dagger.android.DaggerApplication

public class BaseApplication extends DaggerApplication {

    @Override
    protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
        return DaggerAppComponent.builder().application(this).build();
    }
}

accidentally i had used dagger.android.DaggerApplication instead of dagger.android.support.DaggerApplication and was getting android.app.Application cannot be provided without an @Inject constructor or from an @Provides-annotated method , what is the difference between these two classes? is it something related to compatibility?


Solution

  • Yes, it is related to compatibility. The dagger.android.support is compatible with more versions just like the Android support libraries. So it will work on lower Android versions, too. You can check the source code for more info