flutter_secure_storage
flutter_secure_storage copied to clipboard
Android 13 - 1st read after opening the app returns null
Hello everyone,
I am facing an issue that, as soon as I start the application (Android 13), the very first time I read a value from the storage, it is returned as null. The subsequent reads work fine.
Do you have any idea what it might be, please?
Hello @marceloadsj maybe is not your storage object null ?
Hello David. Thx for your reply and apologies my delay. I will double check once more and let you know the exact behaviour.
I remember I did a "dummy read", just to bypass that issue. But I will confirm and return here.
I'm facing the same problem. First calling await read always returns null but subsequent callings return non-null value as expected, even though exactly the same key given.
- Flutter 3.10.6
- flutter_secure_storage: 8.0.0
- Android Emulator API 33 (Android 13)
I remember I did a "dummy read", just to bypass that issue.
Yes, "dummy read" works properly for my case.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
const preference = FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
);
await preference.readAll();
runApp(const MyApp());
}
It's happening on API 30 / Android 11 as well. my solution was to readAll() and get the pref instead of using read()
We can see a log from logcat that might indicate the origin of the problem:
type=1400 audit(0.0:311): avc: denied { read } for name="version" dev="proc" ino=4026532001 scontext=u:r:untrusted_app:s0:c173,c256,c512,c768 tcontext=u:object_r:proc_version:s0 tclass=file permissive=0 app=com.my.app
We were reading the key version.
experience same issue
I am closing all older issues. If this issue still exists in the latest version, please let me know.