google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.45k stars 2.02k forks source link

:app:hiltJavaCompilexxxDebug failed with TaskExecutionException #3143

Closed tudou152 closed 2 years ago

tudou152 commented 2 years ago

AGP: 7.0.4 Upgrade hiltVersion from 2.29.1-alpha to 2.40.5, getting this error during build:

* Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:hiltJavaCompileXiaomiDebug'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145) at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77) at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52) at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61) Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: No shard in com.crossroad.multitimer.DaggerMultiTimerApplication_HiltComponents_SingletonC.ServiceCImpl for: MembersInjectionBinding{key=com.crossroad.multitimer.service.NotificationActionReceiver, explicitDependencies=[DependencyRequest{kind=INSTANCE, key=@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context, requestElement=Optional[appContext], isNullable=false}, DependencyRequest{kind=INSTANCE, key=java.util.concurrent.ConcurrentHashMap<java.lang.Long,com.crossroad.multitimer.ui.widget.timerView.timerDrawable.timerContext.ITimerContext>, requestElement=Optional[timerList], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.data.TimerItemDataSource, requestElement=Optional[timerItemDataSource], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.util.alarm.VibratorManager, requestElement=Optional[vibratorManager], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.service.notification.TimerNotificationManager, requestElement=Optional[timerNotificationManager], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.appWidget.single.remoteViews.RemoteViewsFactory, requestElement=Optional[remoteViewsFactory], isNullable=false}], unresolved=Optional.empty, injectionSites=[InjectionSite{kind=FIELD, element=appContext, dependencies=[DependencyRequest{kind=INSTANCE, key=@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context, requestElement=Optional[appContext], isNullable=false}]}, InjectionSite{kind=FIELD, element=timerList, dependencies=[DependencyRequest{kind=INSTANCE, key=java.util.concurrent.ConcurrentHashMap<java.lang.Long,com.crossroad.multitimer.ui.widget.timerView.timerDrawable.timerContext.ITimerContext>, requestElement=Optional[timerList], isNullable=false}]}, InjectionSite{kind=FIELD, element=timerItemDataSource, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.data.TimerItemDataSource, requestElement=Optional[timerItemDataSource], isNullable=false}]}, InjectionSite{kind=FIELD, element=vibratorManager, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.util.alarm.VibratorManager, requestElement=Optional[vibratorManager], isNullable=false}]}, InjectionSite{kind=FIELD, element=timerNotificationManager, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.service.notification.TimerNotificationManager, requestElement=Optional[timerNotificationManager], isNullable=false}]}, InjectionSite{kind=FIELD, element=remoteViewsFactory, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.appWidget.single.remoteViews.RemoteViewsFactory, requestElement=Optional[remoteViewsFactory], isNullable=false}]}]} at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:163) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94) at org.gradle.internal.compiler.java.IncrementalCompileTask.call(IncrementalCompileTask.java:89) at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:94) at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57) at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:54) at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:97) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37) at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51) at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37) at org.gradle.api.internal.tasks.compile.ModuleApplicationNameWritingCompiler.execute(ModuleApplicationNameWritingCompiler.java:46) at org.gradle.api.internal.tasks.compile.ModuleApplicationNameWritingCompiler.execute(ModuleApplicationNameWritingCompiler.java:36) at org.gradle.jvm.toolchain.internal.DefaultToolchainJavaCompiler.execute(DefaultToolchainJavaCompiler.java:57) at org.gradle.api.tasks.compile.JavaCompile.lambda$createToolchainCompiler$1(JavaCompile.java:232) at org.gradle.api.internal.tasks.compile.CleaningJavaCompiler.execute(CleaningJavaCompiler.java:53) at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory.lambda$createRebuildAllCompiler$0(IncrementalCompilerFactory.java:52) at org.gradle.api.internal.tasks.compile.incremental.SelectiveCompiler.execute(SelectiveCompiler.java:67) at org.gradle.api.internal.tasks.compile.incremental.SelectiveCompiler.execute(SelectiveCompiler.java:41) at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:66) at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:52) at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59) at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51) at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:279) at org.gradle.api.tasks.compile.JavaCompile.performIncrementalCompilation(JavaCompile.java:165) at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:146) at jdk.internal.reflect.GeneratedMethodAccessor2523.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104) at org.gradle.api.internal.project.taskfactory.IncrementalInputsTaskAction.doExecute(IncrementalInputsTaskAction.java:32) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51) at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29) at org.gradle.api.internal.tasks.execution.TaskExecution$2.run(TaskExecution.java:239) at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29) at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68) at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:224) at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:207) at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:190) at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:168) at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:89) at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:40) at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:53) at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:50) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:50) at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:40) at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:68) at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:38) at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48) at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:36) at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41) at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74) at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55) at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51) at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:29) at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:61) at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:42) at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:60) at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:27) at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:188) at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:75) at org.gradle.internal.Either$Right.fold(Either.java:175) at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59) at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:73) at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:48) at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:38) at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:27) at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36) at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22) at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:109) at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:56) at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:56) at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38) at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:73) at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44) at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37) at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27) at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:89) at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:50) at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:114) at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:57) at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:76) at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:50) at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:93) at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:93) at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34) at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38) at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:43) at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:31) at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:40) at org.gradle.api.internal.tasks.execution.TaskExecution$3.withWorkspace(TaskExecution.java:284) at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:40) at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30) at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37) at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27) at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:44) at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:33) at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:76) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:142) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77) at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52) at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182) at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61) Caused by: java.lang.IllegalStateException: No shard in com.crossroad.multitimer.DaggerMultiTimerApplication_HiltComponents_SingletonC.ServiceCImpl for: MembersInjectionBinding{key=com.crossroad.multitimer.service.NotificationActionReceiver, explicitDependencies=[DependencyRequest{kind=INSTANCE, key=@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context, requestElement=Optional[appContext], isNullable=false}, DependencyRequest{kind=INSTANCE, key=java.util.concurrent.ConcurrentHashMap<java.lang.Long,com.crossroad.multitimer.ui.widget.timerView.timerDrawable.timerContext.ITimerContext>, requestElement=Optional[timerList], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.data.TimerItemDataSource, requestElement=Optional[timerItemDataSource], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.util.alarm.VibratorManager, requestElement=Optional[vibratorManager], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.service.notification.TimerNotificationManager, requestElement=Optional[timerNotificationManager], isNullable=false}, DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.appWidget.single.remoteViews.RemoteViewsFactory, requestElement=Optional[remoteViewsFactory], isNullable=false}], unresolved=Optional.empty, injectionSites=[InjectionSite{kind=FIELD, element=appContext, dependencies=[DependencyRequest{kind=INSTANCE, key=@dagger.hilt.android.qualifiers.ApplicationContext android.content.Context, requestElement=Optional[appContext], isNullable=false}]}, InjectionSite{kind=FIELD, element=timerList, dependencies=[DependencyRequest{kind=INSTANCE, key=java.util.concurrent.ConcurrentHashMap<java.lang.Long,com.crossroad.multitimer.ui.widget.timerView.timerDrawable.timerContext.ITimerContext>, requestElement=Optional[timerList], isNullable=false}]}, InjectionSite{kind=FIELD, element=timerItemDataSource, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.data.TimerItemDataSource, requestElement=Optional[timerItemDataSource], isNullable=false}]}, InjectionSite{kind=FIELD, element=vibratorManager, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.util.alarm.VibratorManager, requestElement=Optional[vibratorManager], isNullable=false}]}, InjectionSite{kind=FIELD, element=timerNotificationManager, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.service.notification.TimerNotificationManager, requestElement=Optional[timerNotificationManager], isNullable=false}]}, InjectionSite{kind=FIELD, element=remoteViewsFactory, dependencies=[DependencyRequest{kind=INSTANCE, key=com.crossroad.multitimer.appWidget.single.remoteViews.RemoteViewsFactory, requestElement=Optional[remoteViewsFactory], isNullable=false}]}]} at com.google.common.base.Preconditions.checkState(Preconditions.java:821) at dagger.internal.codegen.writing.ComponentImplementation.shardImplementation(ComponentImplementation.java:309) at dagger.internal.codegen.writing.MembersInjectionMethods.injectMethodExpression(MembersInjectionMethods.java:103) at dagger.internal.codegen.writing.MembersInjectionMethods.lambda$getInjectExpression$0(MembersInjectionMethods.java:89) at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33) at dagger.internal.codegen.writing.MembersInjectionMethods.getInjectExpression(MembersInjectionMethods.java:88) at dagger.internal.codegen.writing.SimpleMethodRequestRepresentation.injectMembers(SimpleMethodRequestRepresentation.java:175) at dagger.internal.codegen.writing.SimpleMethodRequestRepresentation.invokeInjectionMethod(SimpleMethodRequestRepresentation.java:143) at dagger.internal.codegen.writing.SimpleMethodRequestRepresentation.getDependencyExpression(SimpleMethodRequestRepresentation.java:91) at dagger.internal.codegen.writing.PrivateMethodRequestRepresentation.methodName(PrivateMethodRequestRepresentation.java:98) at dagger.internal.codegen.writing.PrivateMethodRequestRepresentation.methodCall(PrivateMethodRequestRepresentation.java:70) at dagger.internal.codegen.writing.MethodRequestRepresentation.getDependencyExpression(MethodRequestRepresentation.java:43) at dagger.internal.codegen.writing.ComponentRequestRepresentations.getDependencyExpression(ComponentRequestRepresentations.java:100) at dagger.internal.codegen.writing.ComponentRequestRepresentations.getDependencyArgumentExpression(ComponentRequestRepresentations.java:170) at dagger.internal.codegen.writing.MembersInjectionMethods.lambda$injectMethodExpression$1(MembersInjectionMethods.java:134) at dagger.internal.codegen.writing.InjectionMethods$InjectionSiteMethod.invoke(InjectionMethods.java:346) at dagger.internal.codegen.writing.InjectionMethods$InjectionSiteMethod.lambda$invokeAll$0(InjectionMethods.java:322) at com.google.common.collect.CollectSpliterators$1WithCharacteristics.lambda$forEachRemaining$1(CollectSpliterators.java:71) at com.google.common.collect.CollectSpliterators$1WithCharacteristics.forEachRemaining(CollectSpliterators.java:71) at dagger.internal.codegen.writing.InjectionMethods$InjectionSiteMethod.invokeAll(InjectionMethods.java:329) at dagger.internal.codegen.writing.MembersInjectionMethods.injectMethodExpression(MembersInjectionMethods.java:127) at dagger.internal.codegen.writing.MembersInjectionMethods.lambda$getInjectExpression$0(MembersInjectionMethods.java:89) at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33) at dagger.internal.codegen.writing.MembersInjectionMethods.getInjectExpression(MembersInjectionMethods.java:88) at dagger.internal.codegen.writing.MembersInjectionRequestRepresentation.membersInjectionInvocation(MembersInjectionRequestRepresentation.java:78) at dagger.internal.codegen.writing.MembersInjectionRequestRepresentation.getComponentMethodImplementation(MembersInjectionRequestRepresentation.java:71) at dagger.internal.codegen.writing.ComponentRequestRepresentations.getComponentMethod(ComponentRequestRepresentations.java:189) at dagger.internal.codegen.writing.ComponentImplementation$ShardImplementation.addInterfaceMethods(ComponentImplementation.java:816) at dagger.internal.codegen.writing.ComponentImplementation$ShardImplementation.generate(ComponentImplementation.java:655) at dagger.internal.codegen.writing.ComponentImplementation$ShardImplementation.access$300(ComponentImplementation.java:428) at dagger.internal.codegen.writing.ComponentImplementation.generate(ComponentImplementation.java:411) at dagger.internal.codegen.writing.ComponentImplementation$ShardImplementation.addChildComponents(ComponentImplementation.java:827) at dagger.internal.codegen.writing.ComponentImplementation$ShardImplementation.generate(ComponentImplementation.java:656) at dagger.internal.codegen.writing.ComponentImplementation$ShardImplementation.access$300(ComponentImplementation.java:428) at dagger.internal.codegen.writing.ComponentImplementation.generate(ComponentImplementation.java:411) at dagger.internal.codegen.componentgenerator.ComponentGenerator.topLevelTypes(ComponentGenerator.java:70) at dagger.internal.codegen.componentgenerator.ComponentGenerator.topLevelTypes(ComponentGenerator.java:36) at dagger.internal.codegen.base.SourceFileGenerator.generate(SourceFileGenerator.java:82) at dagger.internal.codegen.base.SourceFileGenerator.generate(SourceFileGenerator.java:74) at dagger.internal.codegen.ComponentProcessingStep.generateComponent(ComponentProcessingStep.java:127) at dagger.internal.codegen.ComponentProcessingStep.processRootComponent(ComponentProcessingStep.java:112) at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:88) at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:50) at dagger.internal.codegen.validation.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:65) at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:196) at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:55) at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:40) at dagger.spi.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:114) at dagger.spi.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor.process(JavacBasicAnnotationProcessor.kt:63) at org.gradle.api.internal.tasks.compile.processing.DelegatingProcessor.process(DelegatingProcessor.java:62) at org.gradle.api.internal.tasks.compile.processing.IsolatingProcessor.process(IsolatingProcessor.java:50) at org.gradle.api.internal.tasks.compile.processing.DelegatingProcessor.process(DelegatingProcessor.java:62) at org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor.access$401(TimeTrackingProcessor.java:37) at org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor$5.create(TimeTrackingProcessor.java:99) at org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor$5.create(TimeTrackingProcessor.java:96) at org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor.track(TimeTrackingProcessor.java:117) at org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor.process(TimeTrackingProcessor.java:96) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1335) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:936) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)

i'm new to hilt , I've been looking for this problem for a long time, cannot find the answer, please help.

tudou152 commented 2 years ago

it work fine with hilt version 2.29.1-alpha

bcorso commented 2 years ago

@tudou152 thanks! I was able to repro this error with the following setup:

@Component
public interface MyComponent {
    void inject(Bar bar);

    MySubcomponent subcomponent();
}

@Subcomponent
interface MySubcomponent {
  void inject(Foo foo);
}

class Foo {
  @Inject Bar bar;
}

class Bar {
  @Inject Baz baz;
  @Inject Bar() {}
}

class Baz {
  @Inject Baz() {}
}

It may be a few weeks until the fix makes it into a new release, but I think you can work around the issue.

The issue stems from the fact that Bar (in your case NotificationActionReceiver) has both an @Inject constructor and @Inject fields. If you replace the @Inject fields with constructor parameters it should avoid this particular issue. For example, Bar would be rewritten as:

class Bar {
  private final Baz baz;

  @Inject Bar(Baz baz) {
    this.baz = baz;
  }
}
tudou152 commented 2 years ago

@bcorso I have solved it according to your method, thank you very much!

Philipp91 commented 2 years ago

I'm still seeing a similar issue with 2.41, though weirdly only on one of my two BroadcastReceivers. I've determined that this is because of an injection of the receiver elsewhere. Example:

@AndroidEntryPoint
public class FooReceiver extends BroadcastReceiver {
    @Inject
    FooService fooService;
    @Inject
    public FooReceiver() { }
}

This works fine until I inject the receiver elsewhere:

@AndroidEntryPoint
public class FirebaseService extends FirebaseMessagingService {
    @Inject
    FooReceiver fooReceiver;
}

Now I get:

No shard in MyApplication_HiltComponents_SingletonC.ServiceCImpl for: MembersInjectionBinding{key=FooReceiver, explicitDependencies=[DependencyRequest{kind=INSTANCE, key=FooService, requestElement=Optional[fooService], isNullable=false}], membersInjectedType=FooReceiver, unresolved=Optional.empty, injectionSites=[InjectionSite{kind=FIELD, element=fooService, dependencies=[DependencyRequest{kind=INSTANCE, key=FooService, requestElement=Optional[fooService], isNullable=false}]}]}

// EDIT: I realized that I can make my application work without that FirebaseService -> FooReceiver dependency, so I don't need this solved anymore.

Philipp91 commented 2 years ago

The workaround doesn't seem to work at runtime. The compilation succeeds but:

java.lang.RuntimeException: Unable to instantiate receiver FooReceiver: java.lang.InstantiationException: java.lang.Class<FooReceiver> has no zero argument constructor
        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4018)
        at android.app.ActivityThread.access$1400(ActivityThread.java:237)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1924)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)