Closed Lans closed 9 months ago
This error means that Dagger could not find ActivityAppInfoBinding
on the classpath.
This usually happens when you have a setup like the following:
:app -> :lib1 -> :lib2
Where
:app
contains your Application
:lib1
contains AppInfoActivity
:lib2
contains ActivityAppInfoBinding
The issue is that while trying to generate the component in :app
Dagger does not find ActivityAppInfoBinding
on the classpath because Gradle prunes transitive implementation
dependencies from the classpath.
To fix this, you will need to either add a direct dependency from :app -> :lib2
or change the :lib1 -> :lib2
dependency from implementation
to api
so that it does not get pruned.
This error means that Dagger could not find
ActivityAppInfoBinding
on the classpath.This usually happens when you have a setup like the following:
:app -> :lib1 -> :lib2
Where
:app
contains yourApplication
:lib1
containsAppInfoActivity
:lib2
containsActivityAppInfoBinding
The issue is that while trying to generate the component in
:app
Dagger does not findActivityAppInfoBinding
on the classpath because Gradle prunes transitiveimplementation
dependencies from the classpath.To fix this, you will need to either add a direct dependency from
:app -> :lib2
or change the:lib1 -> :lib2
dependency fromimplementation
toapi
so that it does not get pruned.
no lib ,was only one app project
In that case, you'll also want to double check that you've added the import statement for ActivityAppInfoBinding
in the AppInfoActivity.kt
source file, as a missing import statement can also lead to this error.
In that case, you'll also want to double check that you've added the import statement for
ActivityAppInfoBinding
in theAppInfoActivity.kt
source file, as a missing import statement can also lead to this error.
Hmm, I'm not sure then. It could be a bug in KSP, but I would need an example project to reproduce this locally and test it myself.
Ah, I just noticed from the import that the package is com.lans.auto.databinding
.
There's a known issue with DataBinding classes in KSP, which I think can be handled by https://github.com/google/dagger/issues/4049#issuecomment-1749067296
I looked at IssueTracker and it solves the problem like this, but it still requires the Google team to solve the problem with KSP
androidComponents {
onVariants(selector().all(), { variant ->
afterEvaluate {
// This is a workaround for https://issuetracker.google.com/301245705 which depends on internal
// implementations of the android gradle plugin and the ksp gradle plugin which might change in the future
// in an unpredictable way.
def dataBindingTask = (DataBindingGenBaseClassesTask) project.tasks.named("dataBindingGenBaseClasses" + variant.name.capitalize()).get()
if (dataBindingTask != null) {
project.tasks.getByName("ksp" + variant.name.capitalize() + "Kotlin") {
((AbstractKotlinCompileTool) it).setSource(dataBindingTask.sourceOutFolder)
}
}
}
})
}
androidComponents {
onVariants(selector().all()) { variant ->
afterEvaluate {
project.tasks.getByName("ksp" + variant.name.capitalized() + "Kotlin") {
val dataBindingTask =
project.tasks.getByName("dataBindingGenBaseClasses" + variant.name.capitalized()) as DataBindingGenBaseClassesTask
(this as AbstractKotlinCompileTool<*>).setSource(dataBindingTask.sourceOutFolder)
}
}
}
}