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
2 answers

How to pass parameters in dagger2?

Like the following: public class MainActivity extends Activity { @Inject User mUser1; @Inject User mUser2; @Inject User mUser3; protected void onCreate(@Nullable Bundle savedInstanceState) { // how to inject ... ...... …
Yuri.Zheng
  • 11
  • 2
0
votes
1 answer

How can dagger2 inject objects of the same class with different scopes?

There are 2 scopes in my application, which are 1) Singleton lives along with the application process and 2) UserScope starts immediately after the user log in and ends immediately before the user log out. When user is not logged-in, there's a…
Marvin
  • 1,726
  • 1
  • 17
  • 25
0
votes
1 answer

Create adapter error with Dagger + Retrofit + RxJava

I'm trying to get an Observable using Retrofit. I'm getting this error : Unable to create call adapter for rx.Observable for method…
Laurent
  • 1,661
  • 16
  • 29
0
votes
0 answers

Dagger2 - singleton annotation issue

I have a problem with Dagger2 singleton annotation. My module looks a bit like this: @Module public class MyModule { @Singleton @Provides MyInterface provideSipManager(Context context) { Log.d("running provider"); return…
endriu440
  • 13
  • 4
0
votes
1 answer

Android - Dagger Injection not compiling

I'm in the middle of adding Dagger dependency injection to my Android project. Although Android Studio gives shows me no errors before trying to compile, I cannot get my code to build successfully for some reason. I use the MVPC strcture for my app…
oldsport76
  • 387
  • 2
  • 10
0
votes
1 answer

Do we need injection (Dagger2 for example) between Model and Presenter in MVP structure?

I know we can implement Dagger 2 to inject between Presenter and View layer, but do we need injection between M and P? Can you explain the reason?
LunarS
  • 95
  • 2
  • 10
0
votes
1 answer

Dagger won't generate Dagger classes for Android

I'm trying to set up a project with Dagger. Right now when I build, none of the Dagger* classes are generated for the components, and I'm getting the following errors: Error:(10, 8) error:…
AggieDev
  • 5,015
  • 9
  • 26
  • 48
0
votes
1 answer

How to create activity context dependent object in dagger?

I have a situation, I have injected all objects using Dagger 2, But in one situation I am unable to rectify how to inject the object. Following is the situation mPager.setAdapter(new MyPagerAdapter(this)); Now in the above statement, I have to…
Chetan Gaikwad
  • 1,268
  • 1
  • 13
  • 26
0
votes
1 answer

Inject existing MVP presenter from Activity into Service via Dagger2

I'm working with MVP structure using Dagger 2 I can work really well with Activity & Fragment via property injection to get an instance of a presenter, BaseTopPresenter. My issue is I need to inject my presenter BaseTopPresenter presenter; into a…
Huy Tower
  • 7,769
  • 16
  • 61
  • 86
0
votes
1 answer

why does my dagger component is not found when I use butterknife dependencies?

I´m making an android app that uses dagger + butterknife + recycleviews + retrofit. It all compiles and work wel until I add the butter knife dependencies (the ones related to the apt) in the gradle that after I sync, my Dagger Component is not…
linker85
  • 1,601
  • 5
  • 26
  • 44
0
votes
0 answers

No DaggerComponents Generated

Problem: I am not seeing any Dagger-generated Components classes. I have performed clean, rebuild, make project but still don't get them. I am not using the com.neenbedankt.android-apt plugin as Gradle 2.2.2 doesn't need it. Using: Android Studio…
Subby
  • 5,370
  • 15
  • 70
  • 125
0
votes
1 answer

Easy way to check Dagger 2 dependency cycle?

Here. So after bit of refactoring in my project I've ended up with the dependency cycle SOMEWHERE. My module with @Provided dependencies is huge and it's really hard to understand what exactly is the cause. Here is console…
Rybzor
  • 183
  • 3
  • 12
0
votes
1 answer

Singletone classes injected by dagger with synchronized methods

I use singletone classes, are injected by dagger. But if synchronized methods start running, but they terminates. But if I remove synchronization from methods, they run well. If I inject sungletone classes by dagger, I shouldn't use synchronized…
user3057944
  • 701
  • 1
  • 8
  • 19
0
votes
2 answers

How to use dependency injection with java callbacks

I'm developing an Android app and want to use Dagger as my DI framework. But I don't know how to inject dependencies that use callbacks. For example I want to get the location and I use GoogleApiClient for this: public class LocationProvider…
0
votes
0 answers

Dagger2 can't save fields?

I am using MVP+Dagge2 in my project. the project have a PaymentPresenter, when PaymentActivity invoke PaymentPresenter's method paymentsSize(), then it return 0 I sure the payments size is 1, because I invoked addPaymentToPayments…
Jay Ou
  • 63
  • 2
  • 9