Skip to content

[native_storage] Reinstalling app throws KeyStoreException in NativeStorage().secure.isolated.read() #156

@rubenferreira97

Description

@rubenferreira97

While debugging, I uninstalled and installed my app, and the following exception appeared:

JniException (Exception in Java code called through JNI: javax.crypto.AEADBadTagException
...
android.security.KeyStoreException: Signature/MAC verification failed
...

After some investigation, I found that Android's backup policy is the culprit. It tries to back up old data, and since these cryptographic keys do not match, this error occurs.

For more context, a similar issue is discussed in this package: flutter_secure_storage#43.

Currently, there are two ways to fix this:

Option 1: Disable backup completely:

<application
    ...
        android:allowBackup="false">

Option 2: Keep backup enable but exclude encrypted data used by this plugin:

<application
    ...
        android:allowBackup="true" 
        android:fullBackupContent="@xml/backup_rules">
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <exclude <!-- What to place here ??? --> /> 
</full-backup-content>

This issue asks to get better documentation for this. I also want to ask how to solve this using Option 2, as I don't know what to exclude. Additionally, is it possible to add this exclude directive directly to the dependency itself?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions