https://kotlinlang.org logo
#dagger
Title
# dagger
h

Hovhannes

08/20/2021, 1:44 PM
Hello, I've a difficult question. I use Hilt. I get  this error   'java.lang.IllegalArgumentException: SavedStateProvider with the given key is already registered'. What is the reason?
Copy code
Fragment
private var instance: LoginFragment? = null
 private val viewModel by viewModels<AuthViewModel>()
 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding = FragmentLoginBinding.bind(view)
        instance =this
}

fun login(): String {
    viewModel.login(clientId, partner.toString(), password)
    val clientId = binding.editTextTextEmailAddress.text.toString().trim()

    val encrypted = encrypt(clientId, publicKey)
  
    return encrypted
}
RemoteDataSource
Copy code
private fun getRetrofitClient(): OkHttpClient {

    val str= LoginFragment().getInstance()?.login()
....
g

Gustavo Monteiro

08/26/2021, 6:11 PM
s

Sergio C.

08/28/2021, 2:32 PM
Copy code
private var instance: LoginFragment? = null
what is this??
2 Views