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

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/koin/androidx/viewmodel/GetViewModelKt #2094

Open
shamshadpattani opened this issue Dec 27, 2024 · 0 comments

Comments

@shamshadpattani
Copy link

BUG
The bug is if i use navigation or anywhere in my *ViewModel" show this error

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/koin/androidx/viewmodel/GetViewModelKt

`import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.compose.viewModel

class AuthViewmodel(private val authUseCase: AuthUseCase) : ViewModel() {.............}`
actual fun platformModule(): Module = module {


    single {
        dataStore(get())
    }
    viewModelOf(::AuthViewmodel)
}



 private fun initKoin() {
        val modules = sharedKoinModules + platformModule()

      startKoin {
           androidContext(this@AuditApplication)
            modules(modules)
        }
    }
   

version:
koinCore = "4.0.0"

Error in the page of LoginActivity

class LoginActivity : ComponentActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        WindowCompat.setDecorFitsSystemWindows(window, false)
        setContent {
            AuditTheme {
                    AuditLogin()
            }
        }
    }
}
sealed class Screen(val title: String) {
    data object LoginScreen : Screen("Login")
    data object ClientCodeScreen : Screen("ClientCode")
    data object ForgotPasswordScreen : Screen("Forgot")
    data object ResetPasswordScreen : Screen("Reset")
    data object LoginSuccessScreen : Screen("Success")
}

@Composable
fun AuditLogin() {
    val navController = rememberNavController()

    Scaffold(
        containerColor = Color.Transparent,
        contentColor = MaterialTheme.colorScheme.onBackground,
        contentWindowInsets = WindowInsets(0, 0, 0, 0)
    ) { padding ->
        Row(
            Modifier
                .fillMaxSize()
                .padding(padding)
                .windowInsetsPadding(
                    WindowInsets.safeDrawing.only(
                        WindowInsetsSides.Horizontal
                    )
                )
        ) {
            val authViewmodel  = koinViewModel<AuthViewmodel>()
            NavHost(navController, startDestination = Screen.ClientCodeScreen.title) {
                // ClientCodeScreen Composable
                composable(Screen.ClientCodeScreen.title) {

                    ClientCodeScreen(navigateToLogin = { navController.navigate(Screen.LoginScreen.title) },authViewmodel)

                }
                composable(route = Screen.LoginScreen.title,
                ) { backStackEntry ->
                    LoginScreen(navigateToForgotPasword = {
                        navController.navigate(Screen.ForgotPasswordScreen.title)
                    })
                }

val authViewmodel = koinViewModel()

it show the error

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

1 participant