Fixed
Status Update
Comments
ad...@google.com <ad...@google.com> #2
Thanks for reporting this. We will take a look at FBE and try to land a fix in a future release. In the meantime, as the exception notes, you will want to initialize WorkManager in Application.onCreate or via a ContentProvider to avoid the error.
ki...@google.com <ki...@google.com> #3
Initialize WorkManager in Application.onCreate or via a ContentProvider may cause other error:
08-07 14:03:13.261 5869 5869 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider androidx.work.impl.WorkManagerInitializer: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6366)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5910)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5818)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6618)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: Caused by: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:387)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:372)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.utils.IdGenerator.<init>(IdGenerator.java:47)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.background.systemjob.SystemJobScheduler.<init>(SystemJobScheduler.java:69)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.background.systemjob.SystemJobScheduler.<init>(SystemJobScheduler.java:55)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.Schedulers.createBestAvailableBackgroundScheduler(Schedulers.java:114)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.getSchedulers(WorkManagerImpl.java:228)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:179)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:151)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:133)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.WorkManager.initialize(WorkManager.java:160)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:1928)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:1903)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6363)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: ... 10 more
I will try other ways.
08-07 14:03:13.261 5869 5869 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider androidx.work.impl.WorkManagerInitializer: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6366)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5910)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5818)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6618)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: Caused by: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:387)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:372)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.utils.IdGenerator.<init>(IdGenerator.java:47)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.background.systemjob.SystemJobScheduler.<init>(SystemJobScheduler.java:69)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.background.systemjob.SystemJobScheduler.<init>(SystemJobScheduler.java:55)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.Schedulers.createBestAvailableBackgroundScheduler(Schedulers.java:114)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.getSchedulers(WorkManagerImpl.java:228)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:179)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:151)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:133)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.WorkManager.initialize(WorkManager.java:160)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:1928)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:1903)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6363)
08-07 14:03:13.261 5869 5869 E AndroidRuntime: ... 10 more
I will try other ways.
al...@google.com <al...@google.com> #4
This may actually be fixed in alpha07 (launching later today), but we will take a closer look and get back to you.
ap...@google.com <ap...@google.com> #5
Are you enqueuing Work with WorkManager while in Direct Boot mode (i.e., before the device is unlocked)?
hu...@google.com <hu...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f3e63e3a3432b5fb941aec3d4a21e9a5ea42f1d1
Author: Sumir Kataria <sumir@google.com>
Date: Fri Aug 17 14:34:56 2018
Explicitly label WM components as direct boot unaware.
Because WM defaults to a database in encrypted storage, it
cannot run while in direct boot. By explicitly labelling the
components this way, they cannot inherit a directBootAware
flag from the merged <application> xml.
In the future, we will provide a version of WorkManager that
is direct-boot aware. See the tracking feature request at
https://issuetracker.google.com/112773820 This is something
that might land post-1.0.
Bug: 112665532
Test: Ran some integration tests in a test app.
Change-Id: Ide87b8e4c5dfefb88a54c3ce4c45262335f47e96
M work/workmanager/src/main/AndroidManifest.xml
https://android-review.googlesource.com/734390
https://goto.google.com/android-sha1/f3e63e3a3432b5fb941aec3d4a21e9a5ea42f1d1
Branch: androidx-master-dev
commit f3e63e3a3432b5fb941aec3d4a21e9a5ea42f1d1
Author: Sumir Kataria <sumir@google.com>
Date: Fri Aug 17 14:34:56 2018
Explicitly label WM components as direct boot unaware.
Because WM defaults to a database in encrypted storage, it
cannot run while in direct boot. By explicitly labelling the
components this way, they cannot inherit a directBootAware
flag from the merged <application> xml.
In the future, we will provide a version of WorkManager that
is direct-boot aware. See the tracking feature request at
that might land post-1.0.
Bug: 112665532
Test: Ran some integration tests in a test app.
Change-Id: Ide87b8e4c5dfefb88a54c3ce4c45262335f47e96
M work/workmanager/src/main/AndroidManifest.xml
Description
Exception:
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.os.ResultReceiver"
ResultReceiver in AndroidX Core, it is still in package android/support/v4/os:
Sample project:
Android Studio:
Android Studio 3.3
Build #AI-182.5107.16.33.5199772, built on December 25, 2018
JRE: 1.8.0_152-release-1248-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6