1. SharedPreferences in credential encrypted storage are not available until after user is unlocked
解决方案
在Android 7.0以后如果要在开机未解锁前启动一个应用需要加上
<application
android:directBootAware="true"
虽然加上android:directBootAware="true"可以启动了但是不能访问SharedPreferences等数据。
再加上该属性:android:defaultToDeviceProtectedStorage=“true”
<application
android:directBootAware="true"
android:defaultToDeviceProtectedStorage="true"