question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AndroidX Support Library classes cause binding failure

See original GitHub issue

Versions: Dagger 2.16 Android Studio 3.2 Beta 1 Support Library: androidx.appcompat:appcompat:1.0.0-alpha3

When I use dagger.android.support.DaggerApplication as the base class for my Application, I receive this error upon compilation.

:app:kaptGenerateStubsDebugKotlin
e: C:\Users\Mitchell\StudioProjects\AndroidXDatabindingBug\app\build\tmp\kapt3\stubs\debug\com\github\magneticflux\androidxdatabindingbug\di\AppComponent.java:10: error: [Dagger/MissingBinding] java.util.Map<java.lang.Class<? extends androidx.fragment.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends androidx.fragment.app.Fragment>>> cannot be provided without an @Provides-annotated method.
    public abstract void inject(@org.jetbrains.annotations.NotNull()
                         ^
      java.util.Map<java.lang.Class<? extends androidx.fragment.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends androidx.fragment.app.Fragment>>> is injected at
          dagger.android.DispatchingAndroidInjector.<init>(injectorFactories)
      dagger.android.DispatchingAndroidInjector<androidx.fragment.app.Fragment> is injected at
          dagger.android.support.DaggerApplication.supportFragmentInjector
      com.github.magneticflux.androidxdatabindingbug.MyApplication is injected at
          com.github.magneticflux.androidxdatabindingbug.di.AppComponent.inject(com.github.magneticflux.androidxdatabindingbug.MyApplication)
:app:kaptDebugKotlin FAILED

FAILURE: Build failed with an exception.

When I replace import dagger.android.support.DaggerApplication with import dagger.android.DaggerApplication, the error goes away but I am unable to use DaggerAppCompatActivity or DaggerFragment from the support libraries.

A minimal project to reproduce the issue is located here: magneticflux-/AndroidXDagger2Bug, simply try to use the support library features and it will fail to compile.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
ronshapirocommented, Jul 5, 2018

If you’re using the support application, you need AndroidInjectionSupportModule

0reactions
magneticflux-commented, Jul 5, 2018

That makes sense, thanks for explaining it; I don’t have much experience with the advanced features of Dagger 2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't resolve Android databinding class - Stack Overflow
By default, a Binding class will be generated based on the name of the layout file, converting it to Pascal case and suffixing...
Read more >
Troubleshooting Bindings - Xamarin.Android - Microsoft Learn
Android from binding the Android library and present themselves as error messages in the build log. This guide will provide some tips for ......
Read more >
Generated binding classes - Android Developers
The Data Binding Library generates binding classes that are used to access the layout's variables and views. This page shows how to create...
Read more >
Jetifier fails to convert Databinding classes, resulting in a ...
android.databinding.* classes) can be used in a AndroidX-based application. This issue prevents us to ship our library for both android.support ...
Read more >
Troubleshooting for Xamarin.Android binding project - Allen
This issue can be caused by that you directly build the project after adding the jar package without setting its build action. Binding...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found