android - 设备上的文件系统处于错误状态。 WorkManager 无法访问应用程序的内部数据存储

标签 android android-workmanager

当我将工作管理器库添加到 android studio 并运行应用程序时,它会因以下错误而崩溃:

E/SQLiteLog: (14) cannot open file at line 37816 of [c255889bd9]
    (14) os_unix.c:37816: (13) lstat(/data/user/0/com.example/no_backup/androidx.work.workdb) - 
    (1) Process m.example : Pid (13632) Uid (11395) Euid (11395) Gid (11395) Egid (11395)
    (1) osStat failed "/data/user/0/com.example/no_backup/androidx.work.workdb" due to error (13)
    (1) osStat failed "/data/user/0/com.first.academy/no_backup" due to error (13)
    (1) Stat of /data/user/0/com.example : st_mode(40700) st_uid(11385) st_gid(11385) st_ino(164253)
    (1) Stat of /data/user/0 : st_mode(40771) st_uid(1000) st_gid(1000) st_ino(131074)
    (1) Stat of /data/user : st_mode(40711) st_uid(1000) st_gid(1000) st_ino(655366)
    (1) Stat of /data : st_mode(40771) st_uid(1000) st_gid(1000) st_ino(2)
    .....


E/SQLiteDatabase: Failed to open database '/data/user/0/com.example/no_backup/androidx.work.workdb'.
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1806 SQLITE_CANTOPEN_EACCES[1806]): Could not open database
...

E/WM-ForceStopRunnable: The file system on the device is in a bad state. WorkManager cannot access the app's internal data store.
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1806 SQLITE_CANTOPEN_EACCES[1806]): Could not open database
...

E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
    Process: com.example, PID: 13632
    java.lang.IllegalStateException: The file system on the device is in a bad state. WorkManager cannot access the app's internal data store.
        at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:115)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1806 SQLITE_CANTOPEN_EACCES[1806]): Could not open database
....

这是我添加的库:
implementation "androidx.work:work-runtime-ktx:2.4.0"
当我删除此库时,它再次起作用。不知道是设备问题还是app问题。

最佳答案

我设法通过将其添加到 AndroidManifest.xml 来解决此问题:

 <provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    tools:node="merge">
    <!-- If you are using androidx.startup to initialize other components -->
    <meta-data
        android:name="androidx.work.WorkManagerInitializer"
        android:value="androidx.startup"
        tools:node="remove" />
 </provider>
我从这里的文档中得到了这个:
https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration

关于android - 设备上的文件系统处于错误状态。 WorkManager 无法访问应用程序的内部数据存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63434025/

相关文章:

java - 如何生成随机字母数字字符串并将其插入同一( Activity )页面上的组的登录/注册框

android - 未调用 Workmanager Worker 类 doWork() 方法

c# - 如何在 Xamarin Android 中实现 JobScheduler

android - 插入设备时如何使用 WorkManager 创建作业?

android - 我们可以使用 WorkManager 在其他 UniqueWork 的队列中添加另一个 UniqueWork

android - ListView 的 ScrollingViewBehavior

android - 系统/应用程序中的 adb start(run) .apk

android - Android-如何从Maven Central导入库?

java - 从 jni 访问加速度计

android - Foreground Coroutine Worker 导致 android.app.RemoteServiceException : Context. startForegroundService() 然后没有调用 Service.startForeground()