flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

Android 13 - 1st read after opening the app returns null

Open marceloadsj opened this issue 2 years ago • 6 comments
trafficstars

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?

marceloadsj avatar May 10 '23 11:05 marceloadsj

Hello @marceloadsj maybe is not your storage object null ?

DavidIjsud avatar Jun 28 '23 00:06 DavidIjsud

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.

marceloadsj avatar Jul 11 '23 14:07 marceloadsj

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());
}

Seo-4d696b75 avatar Jul 25 '23 13:07 Seo-4d696b75

It's happening on API 30 / Android 11 as well. my solution was to readAll() and get the pref instead of using read()

kdomingo avatar Oct 14 '23 13:10 kdomingo

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.

feinstein avatar Apr 02 '24 03:04 feinstein

experience same issue

softkot avatar Apr 17 '24 14:04 softkot

I am closing all older issues. If this issue still exists in the latest version, please let me know.

juliansteenbakker avatar Aug 13 '24 20:08 juliansteenbakker