Questions tagged [dagger]
Dagger is a dependency injection library for Java and Android.
1,478
questions
0
votes
0
answers
17
views
Execution failed for task ':app:kaptDebugKotlin' after trying to run code in Android Studio
Im trying to run a code, the code worked before but now its just not compiling, after formatting PC, I am getting this error log:
FAILURE: Build failed with an exception.
* What went wrong:
Execution ...
12
votes
5
answers
12k
views
Hilt creating different instances of view model inside same activity
After recently migrating from Dagger to Hilt I started observing very strange behavior with respect to ViewModels. Below is the code snippet:
@HiltAndroidApp
class AndroidApplication : Application() {...
3
votes
1
answer
70
views
Android Dagger ComponentProcessingStep was unable to process
I'm trying to upgrade older version project to support SDK 33 and getting this error while compile.
error: ComponentProcessingStep was unable to process 'com.irokotv.dagger.AppComponent' because 'com....
0
votes
1
answer
27
views
Unable to instantiate application "com.company.application" java.lang.ClassNotFoundException: Didn't find class "com.company.application"
I was trying to build an application that uses Dagger Hilt following a tutorial.
I was checking whether the app is working after setting up a list of objects from API but then I kept getting a ...
0
votes
1
answer
33
views
Dagger error: repeats modules with scoped bindings or declarations:
I keep trying to solve this error. And i have no idea what to do. I have 3 subcomponents(astronomy, currentweather and weatherforecast), I also created scopes and modules for each. With an App and ...
0
votes
1
answer
29
views
Dagger2 custom scopes: Are custom scopes not seen on @Inject constructor injections when using provider methods in a module?
The following is the code
Custom Annotation classes:
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class CtxMain
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class ...
2
votes
1
answer
93
views
Crash when the screen needs to be recreated, possible problem with dependency injection (Class has no zero argument constructor)
I'm working on an old Android project. I know a little about Android, but my focus is iOS. So maybe I'm missing something simple here.
Problem:
The Home screen is working, but when it needs to be ...
0
votes
0
answers
21
views
Java AWS Lambda - Avoid passing context too far down tree of calls
I used Dagger to inject dependencies on a Java Lambda:
public class LambdaEntryPointHandler implements RequestHandler<SQSEvent, SQSBatchResponse> {
private final Handler handler;
public ...
71
votes
17
answers
63k
views
Dagger 2 component not generated
In my module, in my base Application class
component = DaggerCompClassComponent.builder()
.classModule(new ModuleClass()).build();
it can not find DaggerCompClassComponent.
I have ...
0
votes
1
answer
30
views
Android provide from hilt
How I can make transfer parameter from fragment to dagger module used hilt?
I would like that
@Module
@InstallIn(SingletonComponent::class)
class TestModule {
@Singleton
@Provides
fun ...
0
votes
0
answers
25
views
dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved- Android Kotlin
Detail Error
ComponentProcessingStep was unable to process 'com.example.daggerhilt.BaseApp_HiltComponents.SingletonC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' ...
2
votes
3
answers
2k
views
Kotlin - Dagger 2 - Component is not generated by Dagger 2 in Android
I'm stuck at this problem when I move from java to Kotlin. Dagger is not generating the DaggerComponent class. I've tried many ways to fix this. This is my Code :
app.gradle :
...
apply plugin: '...
0
votes
2
answers
39
views
android.app.Activity cannot be provided without an @Provides-annotated method
I am trying to implement inapp-updates, I’ve Activity which has a ViewModel I added a method to it to “checkAppUpdates” which invokes “CheckAppUpdateUseCase” which take AppUpdateManager as a ...
0
votes
0
answers
18
views
Manage feature based hilt custom scope
My app is built with a Single Activity and it is feature-based multi-module. All UI is built using composable.
I want to create a custom scope for feature A. When the feature's journey is completed, ...
0
votes
0
answers
22
views
Given component holder class MainActivity does not implement interface GeneratedComponent or interface GeneratedComponentManager
im creating an app with hilt DI and jetpack compose and my app crashes, when i start it. There are parts of code,where i use hilt:
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@...
29
votes
2
answers
42k
views
Dagger: Inject @Named strings?
EDIT 2023-06-28: Unless you have very good reason not to, just use Spring Boot as your platform and use its auto wiring along with all its other goodies coming for free.
EDIT 2018-02-08: Sample ...
0
votes
2
answers
40
views
Execution failed for task app:kaptDebugKotlin after updating firebase crashlytics, analytics and kotlin
Thanks in advance, My problem is that after upgrading the Firebase Crashlytics, Analytics dependencies using firebase-bom:32.2.2 and kotlin version also (from 1.5.21 to 1.8.0), My project got broken ...
0
votes
1
answer
43
views
Dagger and Multiple AWS Lambdas
I am trying to use Java + Dagger to create a few basic lambdas to handle API Gateway requests.
I am trying to use Dagger to inject the AWS clients the different functions will need, but am struggling ...
2
votes
0
answers
246
views
Migrating dagger from kapt to ksp
last time I tried to migrate from kapt to ksp, all libraries with no problem instead of dagger...
see libraries
dagger2_version '2.47'
I got the error logs:
e: [ksp] Cannot use legacy dagger.spi....
9
votes
4
answers
11k
views
Dagger2 where inject @Named @Provides in dependent module?
I use dagger2 demo by https://guides.codepath.com/android/Dependency-Injection-with-Dagger-2.
I want to use cached and non_cached retrofit call. I create in NetModule.java
@Provides @Named("cached")
@...
0
votes
0
answers
24
views
Dagger Circular Dependency Deadlock
Is it possible for Dagger to deadlock while providing for dependencies? For example, there is a circular dependency between Class A and Class B because both inject each other like this:
class ClassA @...
2
votes
0
answers
49
views
NoClassDefFoundError for singleton in dagger hilt
I have an abstract class
abstract class AccessEnablerDelegate : IAccessEnablerDelegate {}
Using dagger over another class for singleton
@Singleton
class AdobePassAuthentication @Inject constructor(@...
0
votes
1
answer
38
views
How to share ViewModel and its scope across fragments?
I have a small app where one ViewModel has been shared between Fragment and FragmentDialog. It shares not only logic, but also a state. It works fine until I have added one more fragment which uses ...
0
votes
1
answer
156
views
How to fix incompatibility between kapt, Java's and Kotlin's versions, using Dagger?
I have one problem in my Android project. I discovered this error:
compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) jvm target ...
0
votes
0
answers
38
views
Dagger/MissingBinding androidx.lifecycle.ViewModelProvider cannot be provided without an @Inject constructor or an @Provides-annotated method
How can I solve this problem, I know there are some issues by ViewModelProvider, but I can't solve it while googling. But, maybe different errors cause this bug
Complete error is like this:
D:\coding\...
11
votes
2
answers
4k
views
Android Hilt - multi module project cast error
I am trying to use hilt for my project which contains dynamic features. I am facing an error that I cannot fully understand why. I get an error like this:
java.lang.ClassCastException: com.social....
2
votes
3
answers
797
views
View binding error : Member Injector is defined multiple times
I am trying to move a large scale app to view binding. we are using dagger.android at a lot of areas, so i am guessing the View Binding and dagger are not faring well. here is the error i am getting :
...
0
votes
1
answer
65
views
Android ActivityViewModels - what happens when activity is destroyed
I am trying to understand a bit of a scenario where we have a viewmodel created using ktx-library extension activityViewModels.
I understood that it can be used by fragments that wants to share ...
1
vote
0
answers
48
views
How to prevent DependencyCycle?
After added to refreshToken I get this error. It make problem because of using a method of AuthsRepository in TokenAuthenticator class. When I removed to using authsRepository that's not make problem. ...
1
vote
2
answers
46
views
Hilt - Fatal Exception when passing object into ViewModel
I am updating my app to use Hilt but am seeing a crash when passing a value into my viewmodel.
MainActivity
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(...
0
votes
0
answers
56
views
App crashes after adding AuthInterceptor to Apollo client
my app crashes after adding AuthInterceptor to the Apollo client and I can't seem to figure out why it crashes.
ERROR:
E FATAL EXCEPTION: main ...
27
votes
4
answers
41k
views
LiveData is not updating its value after first call
I have been beating my head against the wall and I cannot understand why this is happening. I am working with the new Architectural Components for Android and I am having problems updating a LiveData ...
0
votes
0
answers
20
views
error: incompatible types: Class<SplashViewModel> cannot be converted to Class<? extends NonExistentClass>
I have an error " incompatible types: Class cannot be converted to Class<? extends NonExistentClass> "
Mb someone had the same problem
what i've got during compilation
I think ...
5
votes
2
answers
4k
views
I'm getting the 'circular dependency' Android Dagger Hilt error
I checked everything from scratch, but I couldn't find the error. I couldn't find the error, what could it be?
I am getting the following compilation error;
HomeViewModel.java:6: error: [...
1
vote
0
answers
45
views
After setting up Dagger-Hilt, several packages are created
packages image After setting up Dagger-Hilt, several packages are created, including:
dagger.hilt.internal.aggregatedroot.codegen:
hilt_aggregated_deps:
To avoid these packages, what should I do? ...
0
votes
1
answer
45
views
Hilt injection is null
I try to use HIlt injection but the injectet object is null
have all dependencies:
app/build.gradle
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.dagger.hilt.android'
dependencies {
...
0
votes
0
answers
25
views
Provide hilt and dagger injection in one class. Hilt and dagger in one project
I have main DI as dagger framework, but some implementation made by Hilt framework.
But I need to use in one class Injections which made from both framework.
public class MainActivity{
@Inject
...
0
votes
0
answers
36
views
Cannot be provided without an @provides-annotated method for migration from dagger to hilt
Please help me with such error.
I'm trying to use dagger and hilt in one project.
DataSource eas using a dagger, but I want to implement hilt for use.
And hilt shows an error cannot be provided ...
0
votes
1
answer
18
views
Problem following dagger tutorial, section 10 doesn't even compile
I have been trying to follow this tutorial:
https://dagger.dev/tutorial
But I have found several problems with it. The first problems occurs in the section https://dagger.dev/tutorial/01-setup, here ...
0
votes
1
answer
25
views
Dagger injected singleton is reverting to default value when OS initiates process death
I just want to understand if this (title) is normal behavior or if I have implemented dagger injection incorrectly? The steps I am taking to reproduce this bug is
background app
terminate process ...
0
votes
0
answers
17
views
Exception by migration from dagger to hilt
I have exception
Exception is:
Caused by: java.lang.AbstractMethodError: Missing implementation of resolved method 'abstract java.lang.Iterable initSteps()' of abstract class dagger.shaded.auto.common....
40
votes
5
answers
90k
views
Dagger 2: Cannot be provided without an @Provides-annotated method
I just started learning dagger2 and faced a strange issue that looks like a bug to me. Here's the module:
@Module
public class SimpleModule {
@Provides
Cooker providerCooker() {
...
1
vote
2
answers
85
views
How to pass activity context in my ViewModel class?
I am making an app with firebase authentication that uses signInWithEmailAndPassword() to authenticate the users. Now I also need the activity context with signInWithEmailAndPassword(). So, how do I ...
0
votes
1
answer
201
views
Dagger 2 Inject Dependency from custom scope inside my viewmodel
I am trying to create a custom scope for some of my objects, to use them in viewmodels and other places withing my app that do not belong in this scope.
This is what my component and subcomponent look ...
0
votes
1
answer
83
views
Is it possible to use Dagger components and modules from production code when writing Android UI Tests?
I have large android application with lots of library modules and dagger components, and I need to write Android UI tests for them. I don't want to create every single dagger component for each module....
0
votes
0
answers
40
views
Dagger Component is not created
Im using Hedgehog latest version with gradle 8 and kotlin gradle files.
I have AppComponent interface:
@Component
interface AppComponent {
@Component.Builder
interface Builder{
fun ...
-3
votes
1
answer
1k
views
Class handler.GameSessionLambda has no public zero-argument constructor: java.lang.Exception [closed]
I'm working with Lambda in Java and added Dagger2. However I'm having problem injecting objects to my lambda handler.
I'm getting the following error:
enter image description here
Class handler....
0
votes
0
answers
107
views
How to add kapt for local .jar files in KMM project
I am trying to add local .jar files in my KMM project and trying to access with kapt annotation processor. but getting error for following
Unresolved reference : DaggerAppComponent
kapt(files("\...
0
votes
1
answer
158
views
Unresolved reference DaggerAppComponent in Kotlin
Unable to resolve reference DaggerAppComponent and CoreInjectHelper in the below code:
DaggerAppComponent.builder()
.coreComponent(CoreInjectHelper.provideCoreComponent(this))
...
0
votes
0
answers
80
views
How to add hilt dependency in sub module attach it to main module
Hi anyone help solve this issue submodule has Hilt dependency. I wanted to add to main module getting this error
Application class annotated with @HiltAndroidApp has to be defined in an android ...