java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
Asked Answered
F

1

7

Crashes are not getting logged in cashlytics on Google Pixel devices(OS 9.0-pie) and Playstore reports ANR&Crashes as java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked

It is happening while initializing Fabric.with(this, new Crashlytics()), It is also observed that the IllegalStateException is thrown on restart of device and application is registered for LOCKED_BOOT_COMPLETED & BOOT_COMPLETED broadcast intents

E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.connect, PID: 2328
   java.lang.RuntimeException: Unable to create application com..common.app.AppApplication: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5925)
       at android.app.ActivityThread.access$1100(ActivityThread.java:200)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6718)
       at java.lang.reflect.Method.invoke(Native Method)
       at

Has anyone faced the similar issue. Can anyone help in solving this issue?

Ferritin answered 2/4, 2019 at 18:1 Comment(1)
Are you able to duplicate this in a emulator version of the same device?Boule
S
4

I haven't run into the issue myself but here's an article that talks about supporting Direct Boot mode.

https://developer.android.com/training/articles/direct-boot

Here's also a Github link from Google showing how you can access a device's encrypted storage. In the AlarmStorage class.

https://github.com/googlesamples/android-DirectBoot/

Sev answered 3/4, 2019 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.