Hi there 馃憢
I'm trying to migrate my project to use Hilt from Dagger Android.
I've run into an issue where adding @AndroidEntryPoint onto a custom view, produces a compilation issue on the generated custom view component.
The custom view looks similar to the following:
@AndroidEntryPoint
class CustomShapeView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
CustomBaseView<ShapeLayer>(context, attrs, defStyleAttr) {
@Inject
lateinit var customInjectedClass: CustomInjectedClass
And now when I run the build, it breaks with the generated class for the view looking as follows:
/**
* A generated base class to be extended by the @dagger.hilt.android.AndroidEntryPoint annotated class. If using the Gradle plugin, this is swapped as the base class via bytecode transformation.
*/
@Generated("dagger.hilt.android.processor.internal.androidentrypoint.ViewGenerator")
public abstract class Hilt_CustomShapeView<T> extends CustomBaseView<T> implements GeneratedComponentManager<Object> {
private ViewComponentManager componentManager;
Hilt_CustomShapeView(@NotNull Context arg0, @Nullable @Nullable AttributeSet arg1,
int arg2) {
super(arg0, arg1, arg2);
inject();
}
Hilt_CustomShapeView(@NotNull Context arg0, @Nullable @Nullable AttributeSet arg1) {
super(arg0, arg1);
inject();
}
Hilt_CustomShapeView(@NotNull Context arg0) {
super(arg0);
inject();
}
You can see the first two generated constructors for the view has the @Nullable annotation twice on the AttributeSet.
The compilation error is the following:
error: Nullable is not a repeatable annotation type
Hilt_CustomShapeView(@NotNull Context arg0, @Nullable @Nullable AttributeSet arg1,
I tried to remove the @JvmOverloads annotation and create the constructors one by one, but that didn't seem to make a difference either.
I'm not sure if I'm missing something, but I think this is a bug.
I have a suspicion that this is might be due to an issue with JavaPoet 1.12.1. Can you check what version of JavaPoet you're using and try forcing it to 1.11.1?
Hi @Chang-Eric,
Thanks for the suggestion. I haven't included java poet myself in my gradle files. Is it packaged with Hilt?
Yea, it is a dependency of Hilt and other common annotation processors. My guess is that the version in our POM is lower than some other library's processor you are using, so it is resolving to the newer version from the other library processor.
To check the transitive dependencies in your annotation processor classpath do ./gradlew app:dependencies (replace 'app' with your Gradle module using Hilt) and it will output a big list of things, but try to look for either annotationProcessor or kapt, it'll look something like this:
+--- com.google.dagger:hilt-android-compiler:2.28-alpha
| +--- com.google.dagger:dagger:2.28
| | \--- javax.inject:javax.inject:1
| +--- com.google.dagger:dagger-compiler:2.28
| | +--- com.google.dagger:dagger:2.28 (*)
| | +--- com.google.dagger:dagger-producers:2.28
...
In that tree you'll see which processor is using JavaPoet and which ones is declaring a higher version that is forcing all other processor to get updated.
To exclude the transitive JavaPoet that is higher exclude that dep, like this:
kapt('com.other.processor.1.0') {
exclude group: 'com.squareup', module: 'javapoet'
}
If you can confirm this, that would be amazing, because then we can ping the JavaPoet team for a release containing a the fix.
I could only find the androidx.hilt:hilt-compiler:1.0.0-alpha1 is pulling in version 1.12.1 of Java Poet.
+--- com.google.dagger:hilt-android-compiler:2.28-alpha
| +--- com.google.dagger:dagger:2.28
| | \--- javax.inject:javax.inject:1
| +--- com.google.dagger:dagger-compiler:2.28
| | +--- com.google.dagger:dagger:2.28 (*)
| | +--- com.google.dagger:dagger-producers:2.28
| | | +--- com.google.dagger:dagger:2.28 (*)
| | | +--- com.google.guava:failureaccess:1.0.1
| | | +--- com.google.guava:guava:27.1-jre
| | | | +--- com.google.guava:failureaccess:1.0.1
| | | | +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
| | | | +--- com.google.code.findbugs:jsr305:3.0.2
| | | | +--- org.checkerframework:checker-qual:2.5.2
| | | | +--- com.google.errorprone:error_prone_annotations:2.2.0
| | | | +--- com.google.j2objc:j2objc-annotations:1.1
| | | | \--- org.codehaus.mojo:animal-sniffer-annotations:1.17
| | | +--- javax.inject:javax.inject:1
| | | \--- org.checkerframework:checker-compat-qual:2.5.3
| | +--- com.google.dagger:dagger-spi:2.28
| | | +--- com.google.dagger:dagger:2.28 (*)
| | | +--- com.google.dagger:dagger-producers:2.28 (*)
| | | +--- com.google.code.findbugs:jsr305:3.0.1 -> 3.0.2
| | | +--- com.google.guava:failureaccess:1.0.1
| | | +--- com.google.guava:guava:27.1-jre (*)
| | | +--- com.squareup:javapoet:1.11.1 -> 1.12.1
| | | \--- javax.inject:javax.inject:1
| | +--- com.google.code.findbugs:jsr305:3.0.1 -> 3.0.2
| | +--- com.google.googlejavaformat:google-java-format:1.5
| | | +--- com.google.guava:guava:22.0 -> 27.1-jre (*)
| | | \--- com.google.errorprone:javac-shaded:9-dev-r4023-3
| | +--- com.google.guava:failureaccess:1.0.1
| | +--- com.google.guava:guava:27.1-jre (*)
| | +--- com.squareup:javapoet:1.11.1 -> 1.12.1
| | +--- javax.annotation:jsr250-api:1.0
| | +--- javax.inject:javax.inject:1
| | +--- net.ltgt.gradle.incap:incap:0.2
| | +--- org.checkerframework:checker-compat-qual:2.5.3
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61 -> 1.3.71
| | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.71
| | | \--- org.jetbrains:annotations:13.0
| | \--- org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31 -> 1.3.71 (*)
| +--- com.google.code.findbugs:jsr305:3.0.1 -> 3.0.2
| +--- com.google.guava:failureaccess:1.0.1
| +--- com.google.guava:guava:27.1-jre (*)
| +--- com.squareup:javapoet:1.11.1 -> 1.12.1
| +--- javax.annotation:jsr250-api:1.0
| +--- javax.inject:javax.inject:1
| +--- net.ltgt.gradle.incap:incap:0.2
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61 -> 1.3.71 (*)
| \--- org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0 (*)
\--- androidx.hilt:hilt-compiler:1.0.0-alpha01
+--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 (*)
+--- com.google.auto:auto-common:0.10
| \--- com.google.guava:guava:23.5-jre -> 27.1-jre (*)
\--- com.squareup:javapoet:1.12.1
I tried to exclude javapoet from the androidx.hilt:hilt-compiler, it removes it from the dependency tree, but I'm now getting a different compilation error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':events:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
Should I not be using both of the hilt compilers together? I followed the instructions here that said to add the additional kapt processor when trying to use Hilt with Jetpack for ViewModels etc. https://developer.android.com/training/dependency-injection/hilt-jetpack
Worth noting that when I remove the @AndroidEntryPoint annotation on the custom view class (without changing the dependencies), the app compiles and other parts of hilt work 馃挴
I am getting the exact same error @riggaroo pointed out just trying to compile a blank project with a basic structure for hilt described in the docs.
Additional info if required:
kotlin_version = '1.3.72'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
kapt {
correctErrorTypes true
}
implementation "com.google.dagger:hilt-android:2.28-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.28-alpha"
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha01'
There was a regression of square/javapoet#482 in javapoet:1.12.1 (also see discussion in google/bazel-common#105) that causes this issue in Hilt and Dagger.
@ZacSweers, is this something that javapoet plans to fix, and is there an issue on javapoet side tracking this?
Unfortunately, since androidx.hilt:hilt-compiler:1.0.0-alpha01 uses some of the new APIs in javapoet:1.12.1, I don't think excluding or forcing javapoet:1.11.1 will work. In particular, ClassName#canonicalName was added in 1.12.0 and is used by androidx.hilt.AndroidXHiltProcessor:
Caused by: java.lang.NoSuchMethodError: com.squareup.javapoet.ClassName.canonicalName()Ljava/lang/String;
at androidx.hilt.AndroidXHiltProcessor.getSupportedAnnotationTypes(AndroidXHiltProcessor.kt:39)
It's fixed in the javapoet side, just needs a new release! I'm not a maintainer but I'll ping the right folks 馃憤
In the meantime, it would be good to know if folks with a repro case can confirm it's resolved if you try building using the latest snapshot of Javapoet
Snapshots are published to the sonatype snapshots repo: https://oss.sonatype.org/content/repositories/snapshots
You'll need to add that repo to your build and then set the version to 1.13.0-SNAPSHOT
Tried using 1.13.0-SNAPSHOT

Result with gradlew :app:kaptDebugKotlin --stacktrace --debug:
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:kaptDebugKotlin'.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > A failure occurred while executing org.jetbrains.kotlin.gradle.in
ternal.KaptExecution
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.reflect.InvocationTargetException (no error message)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --scan to get full insights.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for t
ask ':app:kaptDebugKotlin'.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:205)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:26
3)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.executeIfValid(ExecuteActionsTaskExecuter.java:203)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.execute(ExecuteActionsTaskExecuter.java:184)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExe
cuter.execute(CleanupStaleOutputsExecuter.java:109)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.FinalizePropertiesTask
Executer.execute(FinalizePropertiesTaskExecuter.java:46)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionMo
deExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsE
xecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter
.execute(SkipOnlyIfTaskExecuter.java:56)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExec
uter.execute(CatchExceptionTaskExecuter.java:36)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecute
r$1.executeTask(EventFiringTaskExecuter.java:77)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecute
r$1.call(EventFiringTaskExecuter.java:55)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecute
r$1.call(EventFiringTaskExecuter.java:52)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$C
allableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$C
allableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$1
.execute(DefaultBuildOperationExecutor.java:165)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.e
xecute(DefaultBuildOperationExecutor.java:250)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.e
xecute(DefaultBuildOperationExecutor.java:158)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.c
all(DefaultBuildOperationExecutor.java:102)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DelegatingBuildOperationExecuto
r.call(DelegatingBuildOperationExecutor.java:36)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecute
r.execute(EventFiringTaskExecuter.java:52)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalT
askNodeExecutor.java:41)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$Invok
eNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$Invok
eNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$Build
OperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$Build
OperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.l
ambda$run$0(DefaultPlanExecutor.java:127)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.e
xecute(DefaultPlanExecutor.java:191)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.e
xecuteNextNode(DefaultPlanExecutor.java:182)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.r
un(DefaultPlanExecutor.java:124)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFa
ilures.onExecute(ExecutorPolicy.java:64)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(Manag
edExecutorImpl.java:48)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThread
Runnable.run(ThreadFactoryImpl.java:56)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkEx
ecutionException: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExec
ution.waitForCompletion(DefaultWorkerExecutor.java:354)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsA
ndGatherFailures(DefaultAsyncWorkTracker.java:142)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultAsyncWorkTracker.access$000(De
faultAsyncWorkTracker.java:34)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultAsyncWorkTracker$1.run(Default
AsyncWorkTracker.java:106)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.Factories$1.create(Factories.java:26)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultWorkerLeaseService.withoutLock
s(DefaultWorkerLeaseService.java:260)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultWorkerLeaseService.withoutProj
ectLock(DefaultWorkerLeaseService.java:171)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultWorkerLeaseService.withoutProj
ectLock(DefaultWorkerLeaseService.java:165)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.StopShieldingWorkerLeaseService.witho
utProjectLock(StopShieldingWorkerLeaseService.java:95)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsA
ndGatherFailures(DefaultAsyncWorkTracker.java:102)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForAll(De
faultAsyncWorkTracker.java:80)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForComple
tion(DefaultAsyncWorkTracker.java:68)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter$3.run(ExecuteActionsTaskExecuter.java:576)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$R
unnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$R
unnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$1
.execute(DefaultBuildOperationExecutor.java:165)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.e
xecute(DefaultBuildOperationExecutor.java:250)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.e
xecute(DefaultBuildOperationExecutor.java:158)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.r
un(DefaultBuildOperationExecutor.java:92)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DelegatingBuildOperationExecuto
r.run(DelegatingBuildOperationExecutor.java:31)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.executeAction(ExecuteActionsTaskExecuter.java:553)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.executeActions(ExecuteActionsTaskExecuter.java:536)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.access$300(ExecuteActionsTaskExecuter.java:109)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:276)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:265)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute
$0(ExecuteStep.java:32)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ExecuteStep.execute(Execut
eStep.java:32)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ExecuteStep.execute(Execut
eStep.java:26)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CleanupOutputsStep.execute
(CleanupOutputsStep.java:63)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CleanupOutputsStep.execute
(CleanupOutputsStep.java:35)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ResolveInputChangesStep.ex
ecute(ResolveInputChangesStep.java:49)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ResolveInputChangesStep.ex
ecute(ResolveInputChangesStep.java:34)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CancelExecutionStep.execut
e(CancelExecutionStep.java:43)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.TimeoutStep.executeWithout
Timeout(TimeoutStep.java:73)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.TimeoutStep.execute(Timeou
tStep.java:54)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CatchExceptionStep.execute
(CatchExceptionStep.java:34)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CreateOutputsStep.execute(
CreateOutputsStep.java:44)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SnapshotOutputsStep.execut
e(SnapshotOutputsStep.java:54)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SnapshotOutputsStep.execut
e(SnapshotOutputsStep.java:38)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.BroadcastChangingOutputsSt
ep.execute(BroadcastChangingOutputsStep.java:49)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CacheStep.executeWithoutCa
che(CacheStep.java:153)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CacheStep.execute(CacheSte
p.java:67)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CacheStep.execute(CacheSte
p.java:41)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.StoreExecutionStateStep.ex
ecute(StoreExecutionStateStep.java:44)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.StoreExecutionStateStep.ex
ecute(StoreExecutionStateStep.java:33)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.RecordOutputsStep.execute(
RecordOutputsStep.java:38)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.RecordOutputsStep.execute(
RecordOutputsStep.java:24)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBe
cause(SkipUpToDateStep.java:92)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$ex
ecute$0(SkipUpToDateStep.java:85)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(S
kipUpToDateStep.java:55)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(S
kipUpToDateStep.java:39)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ResolveChangesStep.execute
(ResolveChangesStep.java:76)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ResolveChangesStep.execute
(ResolveChangesStep.java:37)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInp
utsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInp
utsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ResolveCachingStateStep.ex
ecute(ResolveCachingStateStep.java:94)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ResolveCachingStateStep.ex
ecute(ResolveCachingStateStep.java:49)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CaptureStateBeforeExecutio
nStep.execute(CaptureStateBeforeExecutionStep.java:79)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.CaptureStateBeforeExecutio
nStep.execute(CaptureStateBeforeExecutionStep.java:53)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.ValidateStep.execute(Valid
ateStep.java:74)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$e
xecute$2(SkipEmptyWorkStep.java:78)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(
SkipEmptyWorkStep.java:78)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(
SkipEmptyWorkStep.java:34)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInp
utsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.LoadExecutionStateStep.exe
cute(LoadExecutionStateStep.java:40)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.steps.LoadExecutionStateStep.exe
cute(LoadExecutionStateStep.java:28)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute
(DefaultWorkExecutor.java:33)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExec
uter.executeIfValid(ExecuteActionsTaskExecuter.java:192)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 30 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.reflect.InvocationTargetException
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke
0(Native Method)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:62)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.in
voke(DelegatingMethodAccessorImpl.java:43)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.internal.KaptExecution.run(KaptWit
houtKotlincTask.kt:158)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterW
orkAction.java:50)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.DefaultWorkerServer.execute(Defaul
tWorkerServer.java:50)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.creat
e(NoIsolationWorkerFactory.java:63)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.creat
e(NoIsolationWorkerFactory.java:59)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.classloader.ClassLoaderUtils.executeInClas
sloader(ClassLoaderUtils.java:98)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$
execute$0(NoIsolationWorkerFactory.java:59)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWork
er.java:44)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWork
er.java:41)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$C
allableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$C
allableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor$1
.execute(DefaultBuildOperationExecutor.java:165)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.e
xecute(DefaultBuildOperationExecutor.java:250)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.e
xecute(DefaultBuildOperationExecutor.java:158)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DefaultBuildOperationExecutor.c
all(DefaultBuildOperationExecutor.java:102)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.operations.DelegatingBuildOperationExecuto
r.call(DelegatingBuildOperationExecutor.java:36)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.AbstractWorker.executeWrappedInBui
ldOperation(AbstractWorker.java:41)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute
(NoIsolationWorkerFactory.java:53)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submi
tWork$2(DefaultWorkerExecutor.java:200)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultConditionalExecutionQueue$Exec
utionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultConditionalExecutionQueue$Exec
utionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.work.DefaultConditionalExecutionQueue$Exec
utionRunner.run(DefaultConditionalExecutionQueue.java:131)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 3 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.reflect.InvocationTargetException
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke
0(Native Method)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:62)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.in
voke(DelegatingMethodAccessorImpl.java:43)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnot
ationProcessing(annotationProcessing.kt:76)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnot
ationProcessing$default(annotationProcessing.kt:35)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 28 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.sun.tools.javac.processing.AnnotationProcessingError
: java.util.NoSuchElementException: Collection contains no element matching the predicate.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnv
ironment.callProcessor(JavacProcessingEnvironment.java:984)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnv
ironment.discoverAndRunProcs(JavacProcessingEnvironment.java:888)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnv
ironment$Round.run(JavacProcessingEnvironment.java:1214)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnv
ironment.doProcessing(JavacProcessingEnvironment.java:1326)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnno
tations(JavaCompiler.java:1258)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnno
tations(JavaCompiler.java:1157)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 34 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.util.NoSuchElementException: Collection contains no
element matching the predicate.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at androidx.hilt.assisted.AssistedFactoryGenerator.getCreateMetho
dSpec(AssistedFactoryGenerator.kt:135)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at androidx.hilt.assisted.AssistedFactoryGenerator.generate(Assis
tedFactoryGenerator.kt:58)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at androidx.hilt.lifecycle.ViewModelGenerator.generate(ViewModelG
enerator.kt:82)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at androidx.hilt.lifecycle.ViewModelInjectStep.process(ViewModelI
njectStep.kt:56)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at androidx.hilt.AndroidXHiltProcessor.process(AndroidXHiltProces
sor.kt:51)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcess
or.process(incrementalProcessors.kt)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annot
ationProcessing.kt:147)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnv
ironment.callProcessor(JavacProcessingEnvironment.java:972)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 39 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
[ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
[ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 16s
@ispam, that looks like it might be a different issue in androidx.hilt.assisted.AssistedFactoryGenerator. Specifically, this part:
Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
at androidx.hilt.assisted.AssistedFactoryGenerator.getCreateMethodSpec(AssistedFactoryGenerator.kt:135)
at androidx.hilt.assisted.AssistedFactoryGenerator.generate(AssistedFactoryGenerator.kt:58)
at androidx.hilt.lifecycle.ViewModelGenerator.generate(ViewModelGenerator.kt:82)
at androidx.hilt.lifecycle.ViewModelInjectStep.process(ViewModelInjectStep.kt:56)
at androidx.hilt.AndroidXHiltProcessor.process(AndroidXHiltProcessor.kt:51)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:972)
... 39 more
@danysantiago any idea? Looks like one of the .first() calls is failing to find a factory method or assisted parameter but I can't really tell which since the line numbers aren't matching up.
Yeah so removing the @Assited in ViewModels makes the app compile and works fine. I also tried removing 1.13.0-SNAPSHOT and the app is able to fully compile.
Is this still unrelated? Should i create a new issue?.
Yup, that is unrelated, where were you placing the @Assisted annotation?
Yes @danysantiago inside ViewModel constructor
Sorry, can you be more specific. In the constructor itself or in a parameter of the constructor and which parameter? If you can share the ViewModel constructor, even better.
Sorry, sure:
Compiles:
class LoginViewModel
@ViewModelInject constructor() : ViewModel()
Cant complete app:kaptDebugKotlin:
class LoginViewModel
@ViewModelInject constructor(@Assisted val navigator: LoginNavigator) : ViewModel()
@Module
@InstallIn(ActivityRetainedComponent::class)
class LoginActivityModule{
@Provides
fun provideLoginActivity(activity: LoginActivity): LoginActivity = activity
@Provides
fun provideLoginNavigatorImpl(activity: FragmentActivity) = LoginNavigatorImpl(activity)
@Provides
fun provideLoginNavigator(impl: LoginNavigatorImpl): LoginNavigator = impl
@AndroidEntryPoint
class LoginActivity : AppCompatActivity()
Thanks - @Assisted is only meant to be used with 'assisted-injected' dependencies, such as SavedStateHandle, you don't need it for your LoginNavigator. This is unrelated to the original issue and there is a check that should have catch this so I'll investigate that separately. Thanks for sharing.
In the meantime, it would be good to know if folks with a repro case can confirm it's resolved if you try building using the latest snapshot of Javapoet
I can confirm forcing javapoet to 1.13.0-SNAPSHOT fixed this issue for me.
Heard back and they're going to target releasing this week 馃憤
Just confirmed on my side, forcing the dependency to 1.13.0-SNAPSHOT also fixes this for me.
JavaPoet 1.13.0 is available now on maven central: https://repo1.maven.org/maven2/com/squareup/javapoet/1.13.0/
Thanks to @egorand for the quick turnaround on it!
How do you force javapoet 1.13.0 version?
I added kapt 'com.squareup:javapoet:1.13.0' and issue is gone.
this solves all problems.
for all Hilt depencies
arrayOf(
"com.google.dagger:hilt-android:${Versions.daggerHilt}",
"androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02"
).forEach { dep ->
implementation(dep) {
exclude(group = "javax.annotation", module = "jsr250-api")
}
}
kapt("com.google.dagger:hilt-android-compiler:${Versions.daggerHilt}")
kapt("androidx.hilt:hilt-compiler:1.0.0-alpha02")
Most helpful comment
JavaPoet 1.13.0 is available now on maven central: https://repo1.maven.org/maven2/com/squareup/javapoet/1.13.0/
Thanks to @egorand for the quick turnaround on it!