Auto-Dagger2 | Annotation processor on top of Dagger | Build Tool library
kandi X-RAY | Auto-Dagger2 Summary
kandi X-RAY | Auto-Dagger2 Summary
Auto Dagger2 is an annotation processor built on top of the Dagger2 annotation processor. It basically generates the component for you. The goal is to reduce the boilerplate code required by Dagger2 when you have "empty" or simple components. It is usually the case in Android development. You can also mix manually written components with the ones generated by Auto Dagger2. Auto Dagger2 produces the human-readable code you would (hopefully) write yourself.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Extracts the components from the annotation
- Finds scope annotation
- Validates an annotation value
- Finds the type of an annotation
- Compose a component
- Returns the list of types names of this module
- Gets the class name
- Returns the component class name
- Returns the class name of a component
- Injects this activity into the Activity
- Creates a new instance of this component
- Invoked when the component is created
- Returns the set of supported AutoComponents
- Injects the main component of this component
- Injects the component
- Creates the instance of this component
- Overrides the superclass to process the extractors
- Extracts the annotations from the annotation
- Get the types of auto component annotation
- Checks if an annotation is valid for this annotation
- Compose a subcomponent
- Get type names from a list of typeMirrors
- Called when an annotation is annotated
- Extracts the parameter
- Combines the elements
- Processes an element
Auto-Dagger2 Key Features
Auto-Dagger2 Examples and Code Snippets
Community Discussions
Trending Discussions on Auto-Dagger2
QUESTION
I'm trying to create an annotation processor which will process my MVP views (fragments) to auto-generated Subcomponents (similar to https://github.com/lukaspili/Auto-Dagger2, but for the new Dagger 2.10 android injectors)
So far, I've been able to generate appropriate files, but there is a strange error message when compiling generated components
Error:(22, 58) error: @dagger.android.support.FragmentKey methods should bind dagger.android.AndroidInjector.Factory, not dagger.android.AndroidInjector.Factory. See google.github.io/dagger/android
The structure of Factory module and Subcomponent files should be correct, because as soon as I copy-paste the generated classes and create a regular classes (both Factory module and Subcomponent) and use real classes instead of generated ones, the message is no longer shown and compilation succeeds
It seems like the problem lies in AndroidMapKeyValidator
(link), where !MoreTypes.equivalence().equivalent(returnType, intendedReturnType)
call apparently fails, but I don't have much of an experience debugging annotation processors, so I don't know why precisely...
Can maybe anyone help where to search for the problem? Thanks
FYI: MyFragment
does extend android.support.v4.app.Fragment
Generated Factory
@Module
public interface BuildersModule {
@Binds
@IntoMap
@FragmentKey(MyFragment.class)
abstract AndroidInjector.Factory factory(MySubcomponent.Builder builder);
}
Generated subcomponent
@Subcomponent(modules = MyModule.class)
public interface MySubcomponent extends AndroidInjector {
MyPresenter presenter();
@Subcomponent.Builder
abstract class Builder extends AndroidInjector.Builder {}
}
ANSWER
Answered 2017-Aug-26 at 16:45If anyone is interested in solution:
I found out that for some reason, references of ClassType
-s compared during project's compile time are not the same when validating generated method.
And these references, despite the fact that they are pointing to the same class, are checked for equality in auto-common
library in EqualVisitor.visitDeclared
method. Apparently, this can be a bug in auto-common
, because Elements in visitDeclared
are compared by object reference, but not type reference.
So workaround here is to use local fixed copy of auto-common
library and exclude all dependencies of the original library.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Auto-Dagger2
Beware that the groupId changed to com.github.lukaspili.autodagger2.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page