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

The method get(Class) in the type ObjectGraph is not applicable for the arguments

Im trying to add some dependency injection in my android project, so following example what i found i created my module @Module(entryPoints = {MyActivity.class}) public class MyModule { private final Context context; public MyModule…
user902383
  • 8,420
  • 8
  • 43
  • 63
-1
votes
1 answer

How to write Kotlin Unit Test with Mockk and Dagger?

I'm quite a newbie on this aera, and unfortunately following various tutorial doesn't help that much... I'm using data injection pattern (Dagger), so let's consider class A,B,C class C @Inject constructor() { fun doIt(i: Int): Int{ …
chtimi59
  • 469
  • 6
  • 9
-1
votes
1 answer

heroku deployed successfully but MongoDB did not store any data

We used heroku to host an app, which was built by using java and dagger. Even though heroku deployment was successful, but none of the data (in the java code for testing) was stored in MongoDB atlas. We tried the following ways, but cannot find out…
lucyh
  • 179
  • 2
  • 5
  • 14
-1
votes
1 answer

Why Dagger doesn't generate Dagger Component?

Here is the error My dependencies plugins Module Component
-1
votes
2 answers

how to fix "cannot be provided without an @Provides-annotated method." - Kotlin

whenever i try to run the application i am facing this error: error: [Dagger/MissingBinding] api.PrayerTimesInterface cannot be provided without an @Provides-annotated method. and this is the interface: @GET("calendar") suspend fun…
user2
  • 59
  • 1
  • 11
-1
votes
1 answer

is it possible to upload android app that use dagger hilt to playstore?

I have an app using dagger hilt. Is it possible to upload the app the to play store? or should I convert it to dagger 2? I starting to use Hilt and it makes me hate dagger 2 so much
NOOB1223
  • 45
  • 1
  • 4
-1
votes
1 answer

Best practice to get a list of data from Firebase and share it in different activities/fragments

I am learning to properly use MVVM, Dagger2 and Firebase on Android using java. I was wondering what would be the best way to do the following: I need to download a list of data from Firebase once Use the data in a couple of fragments in one…
tyrael864
  • 31
  • 4
-1
votes
1 answer

dagger multibinding, Map> cannot be provided without an @Provides-annotated method

I am trying to implement Realm Version management with dagger2, with this link Adavis Realm Migration, but getting following error, [Dagger/MissingBinding] java.util.Map> cannot be provided without an @Provides-annotated method. public abstract…
Reprator
  • 2,859
  • 2
  • 32
  • 55
-1
votes
1 answer

android testing exception with dagger

The problem I have with this piece of code is that I can't add anything to the test class. Everything in TestModule can't be mocked. I run my android test with AndroidJUnit4 and Mockito. We use Android X and Dagger lib. problem inject object in…
arsalan
  • 33
  • 7
-1
votes
1 answer

Dagger singleton preloading

I want to perform such functionality: User opens first activity, and under the hood Dagger starts to initialize singleton, which I will inject on second activity Navigates to the second activity, and here I inject this singleton to the…
NevMem
  • 41
  • 4
-1
votes
2 answers

Getting cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method. on kotlin dagger2

error: app.sareing.core.sharedPrefs.StringPreference cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method. public abstract void inject(@org.jetbrains.annotations.NotNull() ^ …
Anurag Chutani
  • 591
  • 1
  • 4
  • 15
-1
votes
2 answers

DaggerApplicationComponent not generated in my code?

DaggerApplicationComponent is not generated in my code, I am learning Dagger for android and facing this issue. Below my project files. https://github.com/SK010101/AdvanceAndroidTutorial // component = DaggerApplicationComponent.builder() //…
shivam Kapoor
  • 105
  • 2
  • 3
  • 9
-1
votes
1 answer

Problem with dependency injection into dagger fragment

I'm currently working on a android app and using dagger for dependency injection. I've run into trouble when trying to inject dependencies into fragments. I am using a service for Bluetooth that i provide in the following module. @Module public…
Dargor66
  • 33
  • 2
  • 8
-1
votes
1 answer

Dagger 2 - error: @Provides methods cannot be static

I've just added Dagger to my Android project. I've redesigned some of my classes to the Dependency Injection pattern and used the @Inject annotation on their constructors. I've also created corresponding modules and components. When I try to compile…
-1
votes
1 answer

injecting an activity needed member

I need to inject an "RxPermissions" RX Permissions lib instance to my fragment. Its my (basic) fragment class: public class MapFragment extends Fragment { //an empty ctor @Inject RxPermissions rxPermissions; //need inject. @Override …