question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

correctErrorTypes causes DataBindingComponent compile errors

See original GitHub issue

Not sure whether this is Hilt, Kapt or both, but I was migrating a project from Dagger Android to Hilt and followed the guide by @nuhkoca in https://github.com/google/dagger/issues/2030. However my project refused to compile the generated custom data binding component implementation. I found that a Github repo was created based on @nuhkoca’s gist and was able to narrow it down to this option. I’ve forked the project to demonstrate the problem to https://github.com/dmapr/HiltDataBindingSample, look in app/build.gradle

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
bcorsocommented, May 13, 2021

Thanks! The override issue does indeed look like #665. So just to wrap things up, the main takeaways are:

  1. Use correctErrorTypes = true
  2. Extend an entry point with DataBindingComponent instead of extending the @DefineComponent type directly (Example: https://github.com/google/dagger/issues/2603#issuecomment-840740622).
  3. There’s an issue of needing to override the methods in DataBindingComponent, but this is covered by #665.

If that all sounds correct, then I think we can close this issue now since there’s nothing for us to do outside of #665.

2reactions
bcorsocommented, May 13, 2021

So I guess now for the real question — what’s the best way to handle DataBindingComponent with Hilt? Just use a plain Dagger component as before the migration?

Rather than having the @DefineComponent extend DataBindingComponent you can have your entry point extend it, which is effectively the same thing.

@EntryPoint
@InstallIn(CustomBindingComponent::class)
interface CustomBindingEntryPoint: DataBindingComponent {
   override fun getImageBindingAdapter(): ImageBindingAdapter
}

(Note: technically, you shouldn’t need the override since Dagger should see the method defined in DataBindingComponent. However, it’s likely related with DataBindingComponent not being generated yet. I’ll have to look further to see if there’s anything we can do about it on our side).

Then, to set the data binding component you can use EntryPoints:

DataBindingUtil.setDefaultComponent(
    EntryPoints.get(bindingComponentProvider.get().build(), CustomBindingEntryPoint::class.java))

Or if you really want you can just cast:

DataBindingUtil.setDefaultComponent(bindingComponentProvider.get().build() as DataBindingComponent)
Read more comments on GitHub >

github_iconTop Results From Across the Web

correctErrorTypes causes DataBindingComponent compile errors
correctErrorTypes causes DataBindingComponent compile errors. ... However my project refused to compile the generated custom data binding component ...
Read more >
ERROR : error.NonExistentClass Kotlin In multi module ...
I'm using Android Studio 2.3.3. When compiling the Android Project, I encountered this error: error: error.NonExistentClass. The error appears ...
Read more >
Android – ERROR : error.NonExistentClass Kotlin In multi module ...
When compiling the Android Project, I encountered this error: ... is performed and caused by the dagger class cannot found, the class is...
Read more >
Kapt3 fails build (error: unexpected type) when correctErrorTypes ...
Upgraded my app from 1.2.70 to 1.3.0 and my build started failing with a kapt error. Turning off correctErrorTypes fixes the issue.
Read more >
Using kapt | Kotlin
If the annotation processors used in the build cannot be properly cached, ... kapt { javacOptions { // Increase the max count of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found