[Hilt] Feature Request: Better error message when internal used in @EntryPoint declaration
See original GitHub issueOur 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:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
@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).