Closed dnyaneshEuphotic closed 3 months ago
Hi @dnyaneshEuphotic,
This is definitely unexpected to see.
Amplify creates an installation identifier on the device in the application's sandbox (data/data/
This file simply stores a randomly generated UIUD. This UUID is appended to the shared preference file com.amplify.credentialStore.<UUID>
.
I'm unsure how this has happened but the noBackup/com.amplify.credentialStore.installationIdentifier
file appears to be corrupted and does not contain a UUID as expected.
This will reset the Amplify Auth state on the device, but this should hopefully be resolvable by deleting the installationIdentifier file.
File(applicationContext.noBackupFilesDir, "com.amplify.credentialStore.installationIdentifier").apply {
delete()
}
This would need to be deleted before calling Amplify.configure
.
I would love to hear more about how often you are seeing this issue. Has this been seen on a single device or is this something you are running to often? We have not received any other reports of this happening.
Hi @tylerjroach,
Thank you for your response.
Could you help us identify where we can catch this exception?
try { Amplify.addPlugin(AWSApiPlugin()) Amplify.addPlugin(AWSCognitoAuthPlugin()) Amplify.configure(applicationContext) } catch (e: Exception) { e.printStackTrace() }
If this exception occurs, it doesn't seem to be caught in the catch block.
This appears to be an edge case that hasn't been accounted for and is not catchable at the moment.
Can you please provide more information on how many times you have seen this crash occur. I don't quite understand how the library is even getting into this point.
com.amplify.credentialStore.�+�������5�c�FL�C/��і���mn94�-�W��.xml contains a path separator
is not appended with a valid UUID, so even in this case while signing-in, power off the android device such that it shutsdown immediately.
, I don't see how the device is ending up with a filename that was never used in the first place. Creating that identifier file is a 1-time effort that happens on configuration (not signing in). A device restart during sign in should have no impact on that file.
For your reproduction steps, can you replicate this issue on multiple device types or just a single device? How many times have you seen this issue happen? Are you seeing customers experience this issue in production and at what rate?
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Before opening, please confirm:
Language and Async Model
Kotlin, Kotlin - Coroutines
Amplify Categories
Authentication
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
When our android device shutdown abruptly during authentication. It causing amplify credential shared preferences to get corrupted: Below are the logs: 2024-06-28 20:01:25.135 12564-12564 App com.euphotic.sbcApp I Usb initialized 2024-06-28 20:01:25.137 12564-12564 start com.euphotic.sbcApp I Device is not locked 2024-06-28 20:01:25.139 12564-12564 App com.euphotic.sbcApp I isregistrationchecked is false 2024-06-28 20:01:25.139 12564-12564 start com.euphotic.sbcApp D db file not found 2024-06-28 20:01:25.140 12564-12564 DB_deug com.euphotic.sbcApp D isDeviceRegistered: OA 2024-06-28 20:01:25.141 12564-12564 DB_debug com.euphotic.sbcApp D getDBInstance: DI 2024-06-28 20:01:25.141 12564-12564 DB_debug com.euphotic.sbcApp D buildNitriteDB: DI 2024-06-28 20:01:25.141 12564-12564 DB_debug com.euphotic.sbcApp D buildNitriteDB: try 2024-06-28 20:01:25.262 12564-12596 AndroidRuntime com.euphotic.sbcApp E FATAL EXCEPTION: DefaultDispatcher-worker-3 Process: com.euphotic.sbcApp, PID: 12564 java.lang.IllegalArgumentException: File com.amplify.credentialStore.+������ 5�cFL�C/�і���mn94�-�W��.xml contains a path separator at android.app.ContextImpl.makeFilename(ContextImpl.java:3263) at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:915) at android.app.ContextImpl.deleteSharedPreferences(ContextImpl.java:669) at android.content.ContextWrapper.deleteSharedPreferences(ContextWrapper.java:218) at com.amplifyframework.core.store.EncryptedKeyValueRepository.deleteSharedPreferences(EncryptedKeyValueRepository.kt:118) at com.amplifyframework.core.store.EncryptedKeyValueRepository.openKeystoreWithDefaultMasterKey(EncryptedKeyValueRepository.kt:98) at com.amplifyframework.core.store.EncryptedKeyValueRepository.getOrCreateSharedPreferences(EncryptedKeyValueRepository.kt:67) at com.amplifyframework.core.store.EncryptedKeyValueRepository.access$getOrCreateSharedPreferences(EncryptedKeyValueRepository.kt:32) at com.amplifyframework.core.store.EncryptedKeyValueRepository$sharedPreferences$2.invoke(EncryptedKeyValueRepository.kt:48) at com.amplifyframework.core.store.EncryptedKeyValueRepository$sharedPreferences$2.invoke(EncryptedKeyValueRepository.kt:48) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.amplifyframework.core.store.EncryptedKeyValueRepository.getSharedPreferences(EncryptedKeyValueRepository.kt:48) at com.amplifyframework.core.store.EncryptedKeyValueRepository.get(EncryptedKeyValueRepository.kt:51) at com.amplifyframework.auth.cognito.data.AWSCognitoAuthCredentialStore.retrieveCredential(AWSCognitoAuthCredentialStore.kt:62) at com.amplifyframework.auth.cognito.actions.CredentialStoreCognitoActions$loadCredentialStoreAction$$inlined$invoke$1.execute(Action.kt:70) at com.amplifyframework.statemachine.ConcurrentEffectExecutor$execute$1$1.invokeSuspend(ConcurrentEffectExecutor.kt:26) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@296787f, Dispatchers.Default] 2024-06-28 20:01:25.346 450-1345 BufferQueueDebug surfaceflinger E Application Error: com.euphotic.sbcApp#0 id info cannot be read from 'Application Error: com.euphotic.sbcApp#0' 2024-06-28 20:01:25.941 12564-12564 DB_debug com.euphotic.sbcApp D buildNitriteDB: returning 2024-06-28 20:01:26.245 12564-12564 App com.euphotic.sbcApp I repo size is 0 2024-06-28 20:01:26.246 12564-12564 App com.euphotic.sbcApp I isregistered is false 2024-06-28 20:01:26.254 12564-12564 App com.euphotic.sbcApp I Showing first fragment 2024-06-28 20:01:26.267 12564-12564 App com.euphotic.sbcApp I On Welcome fragment 2024-06-28 20:01:26.267 12564-12564 App com.euphotic.sbcApp I Finished wait
How to handle this exception. How can we clear the particular shared preference key.
Reproduction steps (if applicable)
Code Snippet
Log output