https://kotlinlang.org logo
#android
Title
# android
m

Mercy Jemosop

09/19/2023, 2:29 PM
I have created a RegistrationRepositoryWorker class
Copy code
@HiltWorker
class RegistrationRepositoryWorker @AssistedInject constructor(
    @Assisted private val appContext: Context,
    @Assisted private val workerParams: WorkerParameters,
    private val mylApi: MyApi,

) :
    CoroutineWorker(appContext, workerParams) {}
the code above fails with error Could not create Worker RegistrationRepositoryWorkerbut when I remove the MyApi from constructor it works well. How can I call the API correctly
Copy code
interface  MyApi{
    @POST("register") // Replace with the actual API endpoint
    suspend fun registerUser(@Body request: User): Response<ApiResponse>
}
a

Ahsan Ullah Rasel

09/20/2023, 12:20 AM
Did you declared the instantiation of MyApi in module?
m

Mercy Jemosop

09/20/2023, 1:09 AM
I had missed some implementation in the module. after following this article https://rahul9650ray.medium.com/dagger-hilt-retrofit-coroutines-9e8af89500ab
👍 1