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

ViewModel not found in hilt graph. Please, check if you have a Multibinding #381

Open
ArleyPereira opened this issue Mar 26, 2024 · 1 comment
Labels
di: hilt "Hilt" dependency injection issue docs Improvements or additions to documentation

Comments

@ArleyPereira
Copy link

ArleyPereira commented Mar 26, 2024

I'm trying to implement Screen Model and Hilt and I'm getting an error

Project: Android native
Libiry version: 1.1.0-alpha03
Kotlin: 1.9.0
hilt = "2.50"

Dependencies:
#=================================== Voyager - Navigation ===================================#
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
voyager-screenModel = { module = "cafe.adriel.voyager:voyager-screenmodel", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
voyager-hilt = { module = "cafe.adriel.voyager:voyager-hilt", version.ref = "voyager" }
#=================================== Dagger Hilt ===================================#
dagger-hilt = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-compile = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        setContent {
            Navigator(LoginScreen()) { navigator ->
                SlideTransition(navigator)
            }
        }
    }
    
}
class LoginScreen : Screen {
    @Composable
    override fun Content() {
        val screenModel = getScreenModel<LoginViewModel>()
        LoginScreenContent()
    }
}

@Composable
fun LoginScreenContent() {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.White)
    ) {

    }
}
class LoginViewModel @Inject constructor() : ScreenModel {
    
    init {
        
    }
    
}

Screenshot at Mar 26 17-49-02

@AntsyLich
Copy link

You need to add them to hilt like https://github.com/adrielcafe/voyager/blob/main/samples/android/src/main/java/cafe/adriel/voyager/sample/hiltIntegration/HiltModule.kt

@DevSrSouza DevSrSouza added docs Improvements or additions to documentation di: hilt "Hilt" dependency injection issue labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
di: hilt "Hilt" dependency injection issue docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants