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
-1
votes
1 answer

How to send data to my provides scope object in Dagger 2 every time

I want to send name to this method, which is in module class of dagger 2, I know It's Impossible nut I want to know is there any way to send data every time? @Provides Toast provideToast(String name){ Toast toast = Toast.makeText(context, "",…
-1
votes
2 answers

How to provide retrofit interface to abstract module dagger2

I'm following the new Dagger2 support for android to implement a movies list sample application and below is my use case. Activity Holds a fragment used to load list of movies Fragment uses a presenter to hit an api using retrofit Presenter has a…
user101530
  • 87
  • 12
-1
votes
1 answer

Android kotlin doesn't show dagger error log

I will get straight to the problem. Android studio isn't showing me, the Dagger 2 ( version 2.14.1 ) errors in the logcat. By this I mean. In the below image you can see the error "Error:(29, 10) Unresolved reference: DaggerAppComponent". Which for…
-1
votes
1 answer

Dagger is null at SplashActivity

I use Dagger in my app. As the documentation says, I instatiate it at my Application class as a private static class member, and get it by a getter where I need it. private void initDagger() { appComponent = DaggerAppComponent …
user3057944
  • 701
  • 1
  • 8
  • 19
-1
votes
1 answer

Dagger automatically persisting data

I have a class that's being injected using DI via dagger. However when the activity is destroyed and recreated, the model class seems to contain the data automatically without me insert/repopulating the data. public class MyApplication extends…
user2498079
  • 2,872
  • 8
  • 32
  • 60
-1
votes
1 answer

Dagger and SQLiteAssetHelper

Trying to use dagger to create a single instance of my database helper so I can access it easier from the various fragments in my app. Everytime I launch the app though it closes with the following error: Caused by: java.lang.IllegalStateException:…
DRing
  • 6,825
  • 6
  • 29
  • 45
-1
votes
1 answer

Dagger injects {} method issue

I would like to know why we need to add injects = { FirstFragment.class, DownloadManager.class, BookRefreshTask.class } in application class or module class. as we injecting the fragment and…
gandhi
  • 122
  • 6
-1
votes
1 answer

What is the difference between the implementation of singleton on Dependency Injection frameworks (like Dagger) than the normal static singleton?

I was just having this small conversation with a buddy and he's insisting that the singleton used for Dagger is better than making one through old-school-static-private-variables way. Not that I'm sure he's wrong, I just want to clear up why is it…
Julious Igmen
  • 268
  • 3
  • 9
-2
votes
1 answer

Should I use Dagger2 in library project? Will it cause issues for application?

I am currently working on Android library project. Currently we have pure dependency injection(without any Frameworks). However, we expand our library functionality: providing more modules, separating code into new modules, dynamic delivery and etc.…
Viktor Vostrikov
  • 1,322
  • 3
  • 19
  • 36
-2
votes
2 answers

How to import the packages from https://google.github.io/dagger/api/2.12/dagger/android/package-summary.html into Android Studio Project?

How to import the packages from https://google.github.io/dagger/api/2.12/dagger/android/package-summary.html into Android Studio Project? I was trying for a while but didnt get it
-2
votes
2 answers

Dagger android studio 3

I'm following the tutorial https://www.youtube.com/watch?v=oyFhqydqLzM&t=484s in the minute 7:31, but in my project, I have a problem and don't detect the Dagger component, I attached the picture the dependencies that I am using annotationProcessor…
kevinecd
  • 1
  • 1
-2
votes
2 answers

How can I make a Dagger2 injection nullable?

Here I inject a SimpleDynamicString object to my presenter in a MVP structure. To avoid a NullPointerException, I have to implement this. @Provides @StringForTextView static DynamicString provideDynamicString(Application application) { return…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
-2
votes
2 answers

DaggerComponents not getting generated in android

I am Using https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2 ... and followed all steps I am Able to sync the application and see the Dagger Dependencies Issue I am facing: //DaggerNetComponent is not getting…
Devrath
  • 42,072
  • 54
  • 195
  • 297
-3
votes
1 answer

Class handler.GameSessionLambda has no public zero-argument constructor: java.lang.Exception

I'm working with Lambda in Java and added Dagger2. However I'm having problem injecting objects to my lambda handler. I'm getting the following error: enter image description here Class handler.GameSessionLambda has no public zero-argument…
Raze
  • 21
  • 2
-4
votes
2 answers

Dagger2- Retrofit is not injecting in ApiHelperImpl

Hi I am trying to inject retrofit in ApiHelperImpl.kt class. I have below module and component. AppComponent.kt @Component(modules = arrayOf(AndroidInjectionModule::class, AppModule::class, ActivityBuilder::class)) @Singleton interface AppComponent…
N Sharma
  • 33,489
  • 95
  • 256
  • 444
1 2 3
98
99