Questions tagged [dagger-hilt]

Hilt is a Dagger2-based dependency injection library for Android.

The goals of Hilt are:

  • To simplify Dagger-related infrastructure for Android apps.
  • To create a standard set of components and scopes to ease setup, readability/understanding, and code sharing between apps.
  • To provide an easy way to provision different bindings to various build types (e.g. testing, debug, or release).
1333 questions
-1
votes
1 answer

Hilt Dagger 2, Create instance of any object and injecting to a class

I am converting my existing application to MVVM architecture, I use hilt dagger 2 for dependency injection. In my previous code I use single thread Executor to execute all tasks. Now in the Dependency Injection main Module I would like to create an…
Amir Dora.
  • 2,831
  • 4
  • 40
  • 61
-1
votes
1 answer

Retrofit APIService Injection by Dagger Hilt in MVP Architecture's Model Class

I am trying to inject retrofit APIServices dependency into the model class. Here is My API Module Source Code: @Module @InstallIn(SingletonComponent::class) object ApiModule { @Singleton @Provides fun providesHttpLoggingInterceptor() =…
-1
votes
1 answer

Proper way to inject a class that implements an interface using Hilt

I have BeatPlayer.kt interface BeatPlayer { fun getSession(): MediaSessionCompat fun playSong(extras: Bundle = bundleOf(BY_UI_KEY to true)) fun playSong(id: Long) fun playSong(song: Song) } class BeatPlayerImplementation( private val…
-1
votes
1 answer

How can I fix dagger-hilt?

enter image description here I have tried three different projects however, I am still getting the same error.
-1
votes
1 answer

Screen rotation problem in viewmodel with dagger-hilt with injection

I have a problem with injection dagger into view model.The problem is that losing form inputs when rotating the screen.Is the problem in my injection or initialize my view model? Here is my viewmodel; @HiltViewModel class ProfilIslemViewModel…
-1
votes
1 answer

How can i user hilt Inject RepositoryManager for ViewModel(viewmodel creat by invoke)?

this is my RepositoryManager @Singleton class RepositoryManager @Inject constructor(private val retrofit: Retrofit) { fun obtainRetrofitService(serviceClass: Class): T { return retrofit.create(serviceClass) …
-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

Android Implement factory design pattern like Java

How can I have a Factory method using Android and Hilt/Dagger using the java example code. Is this design pattern possible in Android Hilt/Dagger and how to implement. I can not find a good solution on the web Thanks John public class ScannerFactory…
baliman
  • 588
  • 2
  • 8
  • 27
-2
votes
1 answer

Hilt Multi-module Cannot create an instance of class ViewModel

I'm trying out a new architecture with multi-module and DI though Hilt, I have the following modules: app: Contains MainActivity (which does nothing except holding fragment) featureHome: Contains HomeFragment and HomeViewModel When I start the app…
Biscuit
  • 4,840
  • 4
  • 26
  • 54
-2
votes
1 answer

What are there different when I replace object DatabaseModule with class DatabaseModule?

I'm learning dependency injection, the following Code A is from https://developer.android.com/codelabs/android-hilt#6 It seems that Code B can also work well. What are there different when I replace object DatabaseModule with class…
HelloCW
  • 843
  • 22
  • 125
  • 310
-3
votes
1 answer

How can I dependency injection MediaRecorder with Hilt in Android Studio?

I hope to dependency injection MediaRecorder object with Hilt in Android Studio. But the Code A get the error 'lateinit' modifier is not allowed on properties of nullable types . And the Code B get the error Dagger does not support injection into…
HelloCW
  • 843
  • 22
  • 125
  • 310
-5
votes
1 answer

Android multi module project

I'm trying to setup a multi-module project with bottom navigation fragments and hilt. Is there any github project I can use to start my project faster?
Web Services
  • 77
  • 1
  • 8
1 2 3
88
89