Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dagger2 - "is not a framework type." error

I am trying to use the @ContributesAndroidInjector to provide a class in my dagger module and I'm seeing the error: [ClassName] is not a framework type.

Does anyone know what a "framework type" is and in which cases would a class not be one?

like image 855
amitsaurav Avatar asked Nov 10 '17 19:11

amitsaurav


People also ask

Why dagger2 can not generate its components?

If Dagger2 can not generate its components it means that your code have some errors with Scopes/Modules. Check our your @Provides/Inject methods. You should inject your components into cases where you need instances of classes provided by module. Show activity on this post.

Why does my dagger project keep getting nonexistentclass must be interface error?

I had a project with Dagger injecting something into Presenters At one moment I got a persistent "NonExistentClass.java:3: error: error.NonExistentClass must be INTERFACE" error The root cause was trivial: a rogue copy of the valid @Inject annotated file with unsatisfied dependencies somehow slipped into the project.

How to build a Dagger component in Android Studio?

The generated class will be named DaggerComponentClass, not DaggerCompClassComponent. If you can't run your app in Android Studio to get it built, try Build->Clean project and Build->Rebuild project in the menu.

Why can't I run dagger compiler with Kotlin stubs?

Because Kotlin makes its stubs before Java Annotation Processing runs, Kotlin knows just nothing about OrmaDatabase, and the name of the declaration in stubs will be error.NonExistentClass. This breaks the Annotation Processing tool. It's a kind of kapt limitation Just use plain apt or annotationProcessor for running Dagger compiler.


1 Answers

In my case the error occurred when using dagger 2.20.
The issue drove me crazy so I took a clean example and everything was working correctly until I upgraded the version to 2.20. Then I got the "is not a framework type" error.
I changed the version to 2.19 and everything was working again.

like image 107
Aviv Mor Avatar answered Oct 11 '22 11:10

Aviv Mor