Krishna Upadhya
Krishna Upadhya

Reputation: 151

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

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?

Upvotes: 7

Views: 12547

Answers (1)

joelreeves
joelreeves

Reputation: 1954

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/

Upvotes: 4

Related Questions