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.

[Hilt] Feature Request: Better error message when internal used in @EntryPoint declaration

See original GitHub issue

Our team is experiencing a large learning curve when using Hilt. The two biggest contributors to this learning curve are:

  • flaky compilation (having to do clean builds a lot)
  • confusing error messages

This ticket is a feature request for better error messages when a entry point is declared with the internal keyword. For example:

class Foo {
  ...
  @EntryPoint
  @InstallIn(SingletonComponent::class)
  internal interface SingletonAccessor {
    fun getBar(): Bar
  }
}

In the above example, the reported error is:

ava.lang.ClassCastException: Cannot cast com.example.DaggerDebugMyApplication_HiltComponents_SingletonC to com.example.feature.Foo$SingletonAccessor

This feature might require a better Kotlin annotation processor which I hear is in the pipeline.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DroidPulkitcommented, Feb 4, 2021

My team is still facing the same problem, as of now. Getting cast error, when running androidTest cases java.lang.ClassCastException: Cannot cast com.example.client.DaggerPFAApplication_HiltComponents_SingletonC to com.example.client.osiris.di.components.TestPFAApplicationComponentEntryPoint It’s pretty annoying, if the component class I use is from same module com.example.client.PFAApplicationComponentEntryPoint then atleast the test cases compile and let it run, but I cannot inject Presentor or VM to test cases, as in order to inject, I have to use com.example.client.osiris.di.components.TestPFAApplicationComponentEntryPoint as all test cases are here.

Tried the fix suggested over here: https://dagger.dev/hilt/gradle-setup#classpath-aggregation But it doesn’t help

0reactions
bcorsocommented, Mar 1, 2021

@DroidPulkit sorry, your comment must have slipped through the cracks. I’m going to close this issue because I believe the original feature request was more of a red herring, and it “should” be solved by https://dagger.dev/hilt/gradle-setup#classpath-aggregation.

It sounds like you’re still having issues, but if you don’t mind, can you file a new issue (preferably with a sample project with repro steps, as this may be difficult for us to debug without).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency injection with Hilt | Android Developers
... Declare app permissions · Request app permissions · Explain access to more sensitive information · App permissions best practices · Permissions used...
Read more >
Android + Hilt: Cannot inject interface - kotlin - Stack Overflow
So, the solution is as simple as @Inject(ing) an empty constructor in classes to be injected (where there is not one already, of...
Read more >
Hilt - Android Dependency Injection - YouTube
Hilt is a dependency injection library for Android that reduces the boilerplate of doing manual dependency injection in your project.
Read more >
Hilt — A New Android Dependency Injection Framework
Problems with Hilt · Right now Hilt is only in the alpha stage and API is not finalized. Future API changes might require...
Read more >
Dagger Hilt in Android with Example - GeeksforGeeks
But it is very complex and requires a lot of boilerplate codes in order to set up the Dagger. So, to overcome this...
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