rafi0101 / Android-Room-Database-Backup

Simple tool to backup and restore your room database in Android
MIT License
239 stars 19 forks source link

[Crash] javax.crypto.AEADBadTagException #35

Closed victory316 closed 3 months ago

victory316 commented 3 months ago

App crashes when try to export or import files in latest Galaxy OneUi 6.1 update.

I also removed the encrypt option but it happens same.

Could I get some help or updates on here?

Thank you.

FATAL EXCEPTION: main
Process: com.choidev.livegametracker.dev, PID: 14894
javax.crypto.AEADBadTagException
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:632)
    at javax.crypto.Cipher.doFinal(Cipher.java:2114)
    at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.decryptInternal(AndroidKeystoreAesGcm.java:118)
    at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.decrypt(AndroidKeystoreAesGcm.java:101)
    at com.google.crypto.tink.KeysetHandle.decrypt(KeysetHandle.java:919)
    at com.google.crypto.tink.KeysetHandle.readWithAssociatedData(KeysetHandle.java:804)
    at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:785)
    at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readMasterkeyDecryptAndParseKeyset(AndroidKeysetManager.java:381
    at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:297)
    at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169)
    at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130)
    at de.raphaelebner.roomdatabasebackup.core.RoomBackup.initRoomBackup(RoomBackup.kt:286)
    at de.raphaelebner.roomdatabasebackup.core.RoomBackup.backup(RoomBackup.kt:336)
victory316 commented 3 months ago

I've resolved this one by disabling the allowBackUp option to false in manifest.

But if there is other solution or any updates to use it with allowBackUp true, I'm happy to follow up for it!

Tiemichael commented 3 months ago

I am facing the same issue, and changing the 'allowBackUp' option to false in manifest does not help. Also switching OFF encryption does not help in my case.

The issue seems to be caused by a wrong encryption key in the backup-shared preferences (eg coming from a Google App restore) Would it be possible to stop checking for encryption keys, if encryption is OFF?

My solution was to delete the relevant SharedPreference-file.

rafi0101 commented 2 months ago

@Tiemichael please can you open a new issue for this and if you want also a pull request where you solved the problem