codepath / codepath/android_guides
Possible Errata: Dependency Injection with Dagger 2
- Dominant language
- No language data
- Stars
- 28.3k
- Forks
- 6.2k
- PR merge metrics
- No merged PRs in 30d
Description
# Overview
I have noticed possible errors in the article linked [here](https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2). The section in question is [Subcomponents](https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2#subcomponents). The essence of the error is that I have used the code given in the examples, but they do not build successfully. I managed to get it to build after making some changes. However, I am not sure if the errors in question are introduced by something *I did* or inherently due to the code, considering I don't fully understand Dagger 2 yet.
# Setup
+ I coded the example directly following the previous example using `NetComponent`, `MyApp` etc.
+ `NetComponent` acts as the parent component.
+ `MyActivityScope` is defined using the default manner given in the Scopes section.
## Specifications
+ Android Studio 2.3
+ Dagger v2.10
# Error Message
The error message I am experiencing is: `android.widget.ArrayAdapter cannot be provided without an @Provides- or @Produces-annotated method`, along with other related stacktraces and locally-referencing information.
# Fixes
+ Add `@Named("my_list")` before the `@Inject ArrayAdapter arrayAdapter;` line in `MyActivity`.
+ Add a `void inject(MyActivity m)` method in the subcomponent.
It would be really great if someone could crosscheck and verify.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.