Questions tagged [dagger]

Dagger is a dependency injection library for Java and Android.

Dagger, by Square, is a fast dependency injection library for Java and Android. It is compatible with JSR 330. Dagger intentionally leaves out some features and imposes some restrictions in order to attain rapid startup times by eliminating slow runtime reflection, especially on Android.

Dagger 2 is a fork maintained by Google which eliminates reflection in the graph generation phase.

For instance, Dagger does not support the following:

  1. Method Injections.
  2. private and final field injections.

Useful Links

1471 questions
0
votes
1 answer

Dagger and AndroidAnnotations - how to inject @Pref, @Bean, etc?

I'm using AndroidAnnotations in my project and just hooked Dagger + Robolectric + Espresso in. Currently I have an Activity with SharedPrefences and a class 'injected' by AndroidAnnotations. public class SomeActivity extends Activity { @Pref…
Eugene
  • 59,186
  • 91
  • 226
  • 333
0
votes
0 answers

Dragger View is not Injecting

I've imported the Draggable Panel sample and lib. I am using plain eclipse and ADT I've set up the libs and build path and library projects. Project structure looks like this Also I set up the factory path for the annotation processing. Here is the…
Sunny
  • 14,522
  • 15
  • 84
  • 129
0
votes
1 answer

Ask Dagger to do a re-inject post construction?

I have an Activity, which does an initial inject to get some values. It then subscribes (using Otto of course) to changes from an IntentService (which does a simple sync with my back-end server). After this it begins to do some processing, with…
KG -
  • 7,130
  • 12
  • 56
  • 72
0
votes
1 answer

No injectable members-error when using more than one dagger module in project

I would really like to implement Dagger in my app but I have a hard time to understand how it should be configured correctly. I have two classes that I would like to inject. public class LoginController { @Inject Bus bus; @Inject Context…
Kaschwenk
  • 522
  • 5
  • 16
0
votes
2 answers

Dagger auto injection

I have 3 classes in my simple project using dagger: public class MyActivity extends Activity { @Inject public MyController controller; @Override protected void onCreate(Bundle savedInstanceState) { …
NagRock
  • 316
  • 4
  • 15
0
votes
1 answer

Dagger - What does 'Separate "do" from the "how"' means?

I've been watching Jake's slides about Dagger. At the page #29, he said 'Separate "do" from the "how"'. What specifically does that mean? And what are the benefits of it? https://speakerdeck.com/jakewharton/android-testing?slide=29
Thuy Trinh
  • 2,914
  • 1
  • 22
  • 35
0
votes
1 answer

Build a Map with objects that have dependencies

I have an interface: public interface MyInterface {...} Each implementation of MyInterface has its own (different) dependencies. Example: public class MyObjectOne implements MyInterface { @Inject ServiceA ...; ... } public class…
jabu
  • 1
  • 1
0
votes
1 answer

Fragment-scoped ObjectGraph

I learned how to create Application-scoped ObjectGraph, and @Inject into my Views from it. Then I learned how to create Activity-scoped ObjectGraph, and @Inject into my View's from an Activity's Context. Now I need to learn how to create a…
Adel Nizamuddin
  • 823
  • 14
  • 31
0
votes
1 answer

Any examples of using Dagger (or another DI IoC container) in AAR?

Do you have a simple example of DI built on Gradle? I need to see setter injection used to express an optional dependecy, just as per the standard design pattern. Thank you EDIT To better define the context of the Q... I already have my apk…
user2829483
0
votes
1 answer

Dagger can't find injectable members

I've been trying to setup activity graphs for my Android application with Dagger (v1.1.0). Although it compiles fine, I get this error shown below (full trace here): No injectable members on com.f2prateek.couchpotato.ui.ActivityActionBarController.…
f2prateek
  • 2,034
  • 2
  • 20
  • 26
0
votes
1 answer

Dagger: how to instantiate different ObjectGraphs depending on the build

I'm trying to learn Dependency Injection using Dagger. I understand that in your classes, you won't directly instantiate the object your client code depends on, but declare it with @Inject, create a ObjectGraphs via a Module, and get the object from…
GaRRaPeTa
  • 5,459
  • 4
  • 37
  • 61
0
votes
1 answer

Dagger recursive injection

I'm trying dagger and my current use case is represented by the code below. I tought Dagger would inject the objects recursively ut that doesn't seem to happen. I'm getting null on top.inner. public static class Bottom { } /* public static class…
Filipe Pinheiro
  • 1,082
  • 8
  • 32
0
votes
1 answer

Activity graphs and non-found dependency

I'm starting using the dagger, like it pretty much, but now facing some difficulties. My scenario is as follows: there's an activity and a dependency for it. Dependency is injected to the activity, and requires a reference to that activity. Just…
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
0
votes
2 answers

simple dagger unit test fails

I'm new to dagger. I created a very simply unit test to try to understand how I should use dagger. Unfortunately it fails. I've probably not understood some basic principles of dagger. public class A { @Inject public B b; public B…
Guy Chauliac
  • 640
  • 7
  • 8
0
votes
1 answer

Android-Bootstrap mvn clean package error

I'm trying to use the android bootstrap : https://github.com/donnfelker/android-bootstrap. I clone the code.but when So i try the next command from the app directory : mvn clean package but get Something wrong. [ERROR] Failed to execute goal…
keepcleargas
  • 47
  • 1
  • 5