Jetpack Credential Manager doesn't work on Samsung S23 Ultra

144 Views Asked by At

I'm developing a Kotlin app that uses Jetpack Credential Manager API

I have successfully tested authentication on various physical devices, but I am encountering a strange behavior when testing on my friend's Samsung S23 Ultra. When launching the getCredential request nothing happens, no exceptions are thrown, no results are returned, and I don't see any logs in Logcat. It is important to note that the same code works correctly on other devices running Android 14.

This is a test Activity I made

class MainActivity : ComponentActivity() {
    private lateinit var credentialManager: CredentialManager;
    private val coroutineScope = CoroutineScope(Dispatchers.Main)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        credentialManager = CredentialManager.create(this.baseContext)
        
        setContent {
            ...
            coroutineScope.launch {
                withContext(Dispatchers.Main) {
                    login("client_id")
                }
            }
        }
        
    }

    suspend fun login(serverClientId: String) {
        val requestBuilder = GetCredentialRequest.Builder()
        requestBuilder.addCredentialOption(
            GetGoogleIdOption.Builder().setFilterByAuthorizedAccounts(false)
                .setAutoSelectEnabled(false).setServerClientId(serverClientId).build()
        )
        requestBuilder.addCredentialOption(GetPasswordOption())
        try {
            val response = credentialManager.getCredential(this, requestBuilder.build())
            val credential = response.credential
        } catch (e: Throwable) {
            print(e.message)
        }
    }
}
0

There are 0 best solutions below