Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric causing crash for Android Pie users

I am running an android application with Fabric installed for Crashlytics. For most of my users every thing works without a problem, however some users (All of which are running android Pie, and using a Google phone Pixel 2, Pixel 3) are getting a crash caused by Fabric itself it seems to have something to do with accessing SharedPrefs, see log below.

java.lang.RuntimeException: 
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 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: 
  at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:419)
  at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:404)
  at android.content.ContextWrapper.getSharedPreferences (ContextWrapper.java:174)
  at io.fabric.sdk.android.services.persistence.PreferenceStoreImpl.<init> (PreferenceStoreImpl.java:39)
  at io.fabric.sdk.android.services.common.AdvertisingInfoProvider.<init> (AdvertisingInfoProvider.java:37)
  at io.fabric.sdk.android.services.common.IdManager.<init> (IdManager.java:114)
  at io.fabric.sdk.android.Fabric.with (Fabric.java:2288)
  at com.aaronbrecher.neverlate.NeverLateApp.onCreate (NeverLateApp.java:21)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1154)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5920)
like image 946
Aaron Brecher Avatar asked Dec 10 '18 02:12

Aaron Brecher


1 Answers

This exception occurs, when storage is protected and application is started via LOCKED_BOOT_COMPLETED broadcast.

Code from android.app.ContextImpl:

if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.O) {
   if (isCredentialProtectedStorage()
       && !getSystemService(UserManager.class)
                .isUserUnlockingOrUnlocked(UserHandle.myUserId())) {
     throw new IllegalStateException("SharedPreferences in credential encrypted "
                            + "storage are not available until after user is unlocked");
   }
}   
like image 195
henrichg Avatar answered Oct 05 '22 04:10

henrichg