Questions tagged [dagger-2]

Dagger 2 is a dependency injection framework for Java and Android. It implements the full stack with generated code

Dagger 2 is a compile-time dependency injection framework for and .

It uses code generation and compile-time validation taking the approach started with Dagger 1 to it's ultimate conclusion. Dagger 2 eliminates all reflection and improves code clarity by removing the traditional ObjectGraph/Injector in favor of user-specified @Component interfaces. Dagger 2 implements the full stack with generated code.

Useful Links

3161 questions
1
vote
1 answer

How to inject DialogFragment with Dagger?

please i am using dagger 2 for the DI , how to inject dialog fragment into my activity , and how to use the DaggerDialogFragment class provided by dagger i create my DialogFragmentFactory class DialogFragmentFactory @Inject constructor( private…
B.mansouri
  • 376
  • 7
  • 16
1
vote
3 answers

ClassNotFoundException: config_inputEventCompatProcessorOverrideClassName androidx, running on andoridx crashes

After Migrating to AndroidX(29) running on the AndroidX device Crashes showing ClassNotFoundException: config_inputEventCompatProcessorOverrideClassName the project compiles and runs it crashes when launched in andorid10.0 when clicked on the…
1
vote
1 answer

ViewModel cannot be provided without an @Inject constructor or an @Provides-annotated

Question EDITED I am injecting ViewModelProvider.Factory to BaseActivity like below open class BaseActivity : DaggerAppCompatActivity() { @Inject lateinit var factories: ViewModelProvider.Factory inline fun
1
vote
1 answer

Dagger Construction Injection with Kotlin Class Delegation

I have the following Kotlin Class: @ExperimentalCoroutinesApi class SharedPrefClient @Inject constructor(private val prefs: SharedPreferences) : SharedPreferences by prefs { ... } In Dagger, I get the following error while building…
zoha131
  • 1,758
  • 2
  • 16
  • 18
1
vote
0 answers

Dagger 2 Qualifier not working in Kotlin on Android module

I'm trying to provide 2 Firebase CollectionReference objects with Dagger2 @Provides @Singleton @FirebaseSongsDatabaseReferenceNamed internal fun provideUserSongsDatabaseSnapshotRef(dbRef: FirebaseFirestore): CollectionReference = …
KrzysztofW
  • 57
  • 4
1
vote
2 answers

Single instance for different scopes with dagger 2

Problem I am building an app with a dynamic feature. To provide all the dependencies to the main module and the feature module I am using dagger 2. The feature component is depending on the main component and because of that, the feature component…
1
vote
1 answer

How to inject the creation of a BroadcastReceiver object in Fragment using Dagger2?

I need to inject the creation of NetReceiver object into my Fragment but I get the following error: error: [Dagger/MissingBinding] com.example.myapp.NetReceiver.OnNetCallback cannot be provided without an @Provides-annotated method. Let me show…
1
vote
2 answers

Why @ContributesAndroidInjector doesn't provide Android Framework type

I have simplified my application to get the root of the problem and here is the simplified version. I'm implementing Dagger 2 using following configuration: AppComponent @Component(modules = [ AndroidSupportInjectionModule::class, …
Farid
  • 2,317
  • 1
  • 20
  • 34
1
vote
2 answers

Unable to get Dagger to Inject Viewmodel

I've been following a guide to setup DI in an Android application and as far as I can tell I have everything setup correctly. However, I'm getting the following error: java.lang.RuntimeException: Cannot create an instance of class…
rkr87
  • 85
  • 9
1
vote
1 answer

kotlin.jvm.functions.Function1 cannot be provided without an @Provides-annotated method

Usage/ injection: @Inject @field:Named("MyStringSaverFunction") lateinit var stringSaverFunction: (String) -> Unit My Module @Module(includes = [AbcModule.UiBinding::class]) object AbcModule { @Module interface UiBinding { …
ericn
  • 12,476
  • 16
  • 84
  • 127
1
vote
1 answer

Which is the best approach for communication between modules in clean architecture

I am working on an e-commerce site. I am following clean architecture with MVVM and Dagger 2.But am getting stuck when we need to communicate in between modules, means i have to call some methods and class from one module another. Actual scenario is…
sweet_vish
  • 141
  • 1
  • 8
1
vote
1 answer

Is dependency graph building happen at compile time or runtime in Dagger 2

I have a silly question to ask about Dagger 2. Because I want to be sure. I know that in compile time, Dagger generates code. But for the following code: class MyApplication : Application() { override fun onCreate() { super.onCreate() …
Leem
  • 17,220
  • 36
  • 109
  • 159
1
vote
1 answer

JSON data not showing in the Recylerview MVVM

I'm trying to parse Json in Recyclerview using Data binding. When I run the app it's only showing blank screen with no error/crashes. Json data: { "msg":[ "football", "cricket", "baseball", "rugby", "gulf" ], …
GK007
  • 117
  • 2
  • 15
1
vote
1 answer

Dagger declare subcomponent in module in my case

I am using Dagger version 2.24 About this module declaration with subcomponent: @Module(subcomponents = MySubComponent.class) abstract class MyModule { ... } I understand (if I understand wrongly already here, please point out) this code means…
Leem
  • 17,220
  • 36
  • 109
  • 159
1
vote
1 answer

declare subcomponent in module raise compiler error

I am using Dagger 2.24. I have a subcomponent: @Subcomponent(modules = MyModule.class) public interface MySubComponent { void inject(MyApplication app); } Since my subcomponent is only used by classes of a specific module, so, I try to declare…
Leem
  • 17,220
  • 36
  • 109
  • 159
1 2 3
99
100