Questions tagged dependency-injection

Explore the latest questions and answers asked by our top developers.

Provide service of app module in submodule of multi module android application

It’s a bit difficult to describe what I try to do, therefore some umd diagram: I want to inject a service which is defined in the core module (AccountService) but implemented in the App module into another module (sync). The core module is included in all other modules. The app module includes sync and favorites. […]

By Tobias
Published
Categorized as android, dagger, dagger-2, dependency-injection, multi-module

Sharing property between injected and provided classes which is cannot be provided by Hilt

In an old project, I need to refactor MVP architecture. But first I need to apply DI by using Hilt. I need to provide dependencies to presenter class and the I will inject my presenter class to my activity. Now some of my properties/dependencies cannot be provided. For example I couldn’t provide views. I tried […]

By K tas
Published
Categorized as android, dagger-hilt, dependency-injection, kotlin

Inject a dao into Worker with Hilt problem

I have initiated a worker in my App class like below; @HiltAndroidApp class KutuphanemApplication:Application(),Configuration.Provider { @Inject lateinit var workerFactory: HiltWorkerFactory override fun getWorkManagerConfiguration() = Configuration.Builder() .setMinimumLoggingLevel(android.util.Log.DEBUG) .setWorkerFactory(workerFactory) .build() I want to inject a singleton dao into my worker class for update something in DB. So I am injecting dao like below; @HiltWorker class ClearImageNotInArchiveWorker @AssistedInject […]

Error: org.koin.error.BeanInstanceCreationException: Can’t create definition for Single

I am using koin with below dependency in my android application as below : //Koin dependencies implementation koinDependencies.values() def koinVersion = ‘1.0.2’ It was working fine with the Target API Level 29 but when I changed it to 30, as below : ext { androidCompileSdkVersion = 28 androidMinSdkVersion = 28 androidTargetSdkVersion = 30 } I […]

By Jaimin Modi
Published
Categorized as android, dependency-injection, koin, koin-scope, kotlin

Adding external jar as a dependency not working in android studio

I have an external jar file I am trying to import in android studio, I have tried both the "libs" folder method and the "add dependency" method. They both seem to work and gradle syncs properly. Yet, when I type the class name in the code editor it doesn’t appear as part of my project(i.e […]

By NightStorm
Published
Categorized as android, android-studio, dependency-injection, jar, java

Xamarin: Navigating back does not work when registrating a service platform-specific

My Xamarin App should scan a barcode and send it through to a database. For that, I have a Zebra device, which is configured by using the DataWedgeReceiver.cs and AndroidScanner.cs classes (both platform-specific in android): public AndroidScanner() { _context = Application.Context; _broadcastReceiver = new DataWedgeReceiver(); _broadcastReceiver.ScanDataReceived += (sender, scanData) => { OnScanDataCollected?.Invoke(this, scanData); }; CreateProfile(); […]

By Bucks34
Published
Categorized as android, c#, dependency-injection, xamarin.forms, zebra

Is Hilt or Koin better for implementing in android projects?

I’m a new beginner to Di and learned about dependency injection libraries and known that google is supporting Dagger-Hilt library for Di. I have looked on google and found that koin is a simpler method for di. Now I’m stuck with this that what to use more comfortably and which is more reliable. I had […]

By Ajay K S
Published
Categorized as android, dagger-hilt, dependency-injection, koin

Where is correct place to instanstiate Agora SDK RtmClient object when using MVVM architecture, DI (Hilt) in android app?

I’m new in programming and I’m trying to build my first VideoChat app using MVVM architecture and DI (Hilt) with Agora SDK. I understand that correct way to instantiate mRtmClient, rtcEngine objects is to provide it by DI, like we provide Room or Retrofit objects. But difference from Room and Retrofit is that they need […]

By Janis B
Published
Categorized as agora.io, android, dependency-injection, kotlin, mvvm

How to use multiple Gson instances with Koin?

At the end of the description is the code of the existing project. I added the below lines to that. single { provideGson2() } private fun provideGson2(): Gson { return GsonBuilder().setLenient().create() } private fun provideApi2(gson: Gson): API2 { return ServiceGenerator.generate(BASE_URL_2, API2::class.java, gson) } I need to use instance of provideGson() with provideApi() method, and instance […]

By Ajantha Wijerathna
Published
Categorized as android, dependency-injection, gson, koin, retrofit

Adding dependency injection in ViewModelFactory giving initialisation error

I am trying to implement Dependency injection in ViewModel Following is the code I am using. class BaseViewModelFactory() : ViewModelProvider.Factory { @Inject lateinit var service: LinkoService override fun <T : ViewModel> create(modelClass: Class<T>): T { return modelClass.getConstructor(LinkoService::class.java).newInstance(service) } } class LinkoService @Inject constructor() { private val mainDB = Firebase.firestore var user : UserModel? = null […]

By Muhammad Umar
Published
Categorized as android, dependency-injection, kotlin
1 2 3 27

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq