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

Set Typeface for View Holder TextView using Dagger2 DI

I want to set a custom typeface for a Textview in ListView Adapter ViewHolder. My typeface font file is in assets folder, so I will need a context reference in my adapter class to access the assets path and also I don't want to pass a context…
sumit soni
  • 70
  • 1
  • 7
0
votes
1 answer

Dagger 2 application using library that uses dagger 1

I am finding myself in situation where I am transitioning application from using Dagger 1 to Dagger 2. However this application uses a library that is using Dagger 1 and during my application startup I get following exception E/AndroidRuntime:…
Subodh Nijsure
  • 3,305
  • 5
  • 26
  • 45
0
votes
1 answer

Android dagger2 module cannot be injected into other module

Im trying to learn how to use dagger2. Are you supposed to make a component for every single module you have (and then combine components in "super-components")? I have 2 modules which work, and who used to have individual components. Then i added…
user1202032
  • 1,430
  • 3
  • 15
  • 36
0
votes
2 answers

What is Concrete Call and how is it different from Reflection?

I was studying about the Dagger 2 - dependency injection library for Android - and in many articles, when the autor compares the Dagger 2 with it's older version ( Dagger ), He says this: (...) The new release, as promised, addresses many of the…
regmoraes
  • 5,329
  • 3
  • 24
  • 33
0
votes
1 answer

Why do we need Dependency Injection for singleton classes in java or Android?

For example if I am injecting (Otto)Bus object, using Dagger, then i would have to write more line of code just to specify, at how many places I'm injecting it, in the interface. On the other hand if I just use a singleton class to return Bus…
Saleem Khan
  • 2,285
  • 2
  • 15
  • 12
0
votes
1 answer

Simple gradle dagger java example

I have prepared simple gradle demo project example where dagger 2.2 is used. Demo is on https://github.com/klaun76/gradle-dagger-java-simple-example). But when i changed version to 2.3 i got error: Execution failed for task…
klaun
  • 56
  • 2
0
votes
0 answers

Breakpoints in Provides method get remapped in Eclipse to ProvidesAdapter instead

I am having an issue in Eclipse (with Dagger 1 still). In dagger, for dependency injection (javax.inject), you create a Module class, with provides methods, like this: @dagger.Module class FooModule { @dagger.Provides Something…
Ben
  • 4,785
  • 3
  • 27
  • 39
0
votes
1 answer

Realm Gradle plugin seems to break apt code generation for Dagger

So I'm pretty psyched about the new Realm features added in 0.88 and want to use them in my project. Unfortunately, in 0.88+ it is now neccesary to use a Gradle plugin called realm-android. I am also using Dagger 1 which requires a code generation…
Andrew G
  • 1,547
  • 1
  • 13
  • 27
0
votes
1 answer

Dagger best practice

I'm trying to figure out dagger and having a hard time to grasp the concept of the object graphs. I'm not new to the dependency injection paradigm, I used angular.js in JavaScript and prism in .Net. So I do understand the idea behind it. What I…
Slava Shpitalny
  • 3,965
  • 2
  • 15
  • 22
0
votes
1 answer

How do I use inject a field using a Dagger 2 multi-binding?

I'm trying to support third party extensions using map multibindings, but I can't wrap my head around how it's supposed to provide an extensible infrastructure. It seems like it should be really simple, but the Dagger 2 documentation on…
Cyde Weys
  • 154
  • 2
  • 7
0
votes
0 answers

How to add dagger in my android studio project

I am trying to compress the video using ffmpeg in android. I found one good example and I downloaded the project from https://github.com/WritingMinds/ffmpeg-android-java. It's working fine. When I try to add that ffmpeg library in my project I am…
Vijay
  • 3,152
  • 3
  • 24
  • 33
0
votes
1 answer

Dependency Injection: Dagger removing sub-graph

When you want to add a sub-objectgraph to your global object graph you use: newObjectGraph = objectgraph.plus(new SubModule("SomeConfig")); Now you are done with SubModule and you want to let it go (or perhaps you want to replace it with…
Kasra
  • 3,045
  • 3
  • 17
  • 34
0
votes
0 answers

You must explicitly add it to the 'injects' option in one of your modulesoid.apps.ridematch.payments.SetPaymentActivity

I try to run robolectric + dagger but I get this error 1) sendWrongPaymentDetails(com.google.android.apps.ridematch.payments.SetPaymentActivityTest) java.lang.IllegalArgumentException: No inject registered for…
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
0
votes
1 answer

Dagger 2: injecting singleton with lots of access points

I just started with DI / Dagger 2. I have a huge project. To try dagger 2, I started with injecting my singleton class 'MyPreferences'. This class handles all app actions from and to the SharedPreferences. Auto-injecting the SharedPreferences in the…
Frank
  • 12,010
  • 8
  • 61
  • 78
0
votes
1 answer

How to implement dagger inject before than "onActivityCreated"

when I want use injected object in "onViewCreated" like this: @Inject ItemsManager itemsManager; private RecyclerView mRecyclerView; private ExercisesAdapter mAdapter; private List mModels; public static ExercisesFragment…
maciej
  • 51
  • 2