Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use Inject annotation in @HiltViewModel classes #4

Open
IsakTheHacker opened this issue Mar 3, 2024 · 2 comments
Open

Can't use Inject annotation in @HiltViewModel classes #4

IsakTheHacker opened this issue Mar 3, 2024 · 2 comments

Comments

@IsakTheHacker
Copy link

IsakTheHacker commented Mar 3, 2024

Describe the bug
A clear and concise description of what the bug is.
When using the @HiltViewModel annotation to help with dependency injection it isn't possible to use the @Inject annotations from this library.

To Reproduce

import com.chrynan.inject.Inject

@HiltViewModel
class ExampleViewModel @Inject constructor() : ViewModel() {

}

Expected behavior
No compilation errors such as

@HiltViewModel annotated class should contain exactly one @Inject or @AssistedInject annotated constructor.
@gregkorossy
Copy link

@IsakTheHacker I have the same issue. Did you manage to solve it?
@chRyNaN Any suggestions?

@chRyNaN
Copy link
Owner

chRyNaN commented Dec 17, 2024

Perhaps the Dagger hilt annotation processor doesn't work with typealiases and explicitly expects javax.inject.Inject annotations?

Basically, this project just creates expected @Inject annotations in the common source, and the JVM and Android implementations just use a typealias to the javax.inject.Inject annotations. Something like this:

actual typealias Inject = javax.inject.Inject

There's no special functionality provided. My thoughts are the Hilt annotation processor might not work with typealiases. I'm not sure since I don't use Hilt. But it seems like an issue with their library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants