GCX-HCI / tray

a SharedPreferences replacement for Android with multiprocess support
Apache License 2.0
2.29k stars 273 forks source link

Failed to open database '/data/user/0/com.xxx.xxx/databases/tray.db' #120

Closed toy-lin closed 6 years ago

toy-lin commented 6 years ago

tray Version (E.g. 0.12.0)

0.11.1

How have you setup tray (E.g. Initialized in Application.onCreate, in an Activity, BroadcastReceiver, IntentService, MainThread)

compile 'net.grandcentrix.tray:tray:0.11.1'

Device(s) (E.g. Samsung Galaxy S8)

360Phone

Android Version (E.g. Marshmallow or better API 23)

Android7.1.1

Stacktrace

Stacktrace ``` 10-28 11:54:03.324 20407 20407 W ContextImpl: Failed to ensure /data/user/0/com.xxx.xxx/databases: mkdir failed: EACCES (Permission denied) 10-28 11:54:03.324 20407 20407 E SQLiteLog: (14) cannot open file at line 32456 of [bda77dda96] 10-28 11:54:03.324 20407 20407 E SQLiteLog: (14) os_unix.c:32456: (13) open(/data/user/0/com.xxx.xxx/databases/tray.db) - 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: Failed to open database '/data/user/0/com.xxx.xxx/databases/tray.db'. 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:656) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.provider.TrayContentProvider.getReadableDatabase(TrayContentProvider.java:117) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.provider.TrayContentProvider.query(TrayContentProvider.java:265) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.content.ContentProvider.query(ContentProvider.java:1045) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.content.ContentProvider$Transport.query(ContentProvider.java:245) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.content.ContentResolver.query(ContentResolver.java:534) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.content.ContentResolver.query(ContentResolver.java:475) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.provider.TrayProviderHelper.queryProvider(TrayProviderHelper.java:169) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.provider.ContentProviderStorage.getVersion(ContentProviderStorage.java:216) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.core.Preferences.changeVersion(Preferences.java:258) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.core.Preferences.isVersionChangeChecked(Preferences.java:292) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.core.Preferences.(Preferences.java:58) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.core.AbstractTrayPreference.(AbstractTrayPreference.java:31) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.TrayPreferences.(TrayPreferences.java:43) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at net.grandcentrix.tray.TrayPreferences.(TrayPreferences.java:48) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.xxx.xxx.module.sp.DebugPreferences.(DebugPreferences.java:15) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.xxx.xxx.module.sp.DebugPreferences.getInstance(DebugPreferences.java:24) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.xxx.xxx.module.sp.DebugPreferences.doUseHttp(DebugPreferences.java:42) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.xxx.xxx.QikuApplication.debugSetting(QikuApplication.java:86) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.xxx.xxx.QikuApplication.onCreate(QikuApplication.java:44) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5509) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.app.ActivityThread.-wrap2(ActivityThread.java) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1579) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.os.Handler.dispatchMessage(Handler.java:102) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.os.Looper.loop(Looper.java:154) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at android.app.ActivityThread.main(ActivityThread.java:6244) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at java.lang.reflect.Method.invoke(Native Method) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) 10-28 11:54:03.326 20407 20407 E SQLiteDatabase: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:797) ```

Description (Just a place with additional information, more == better)

passsy commented 6 years ago

Are you calling tray in Application#onCreate?

toy-lin commented 6 years ago

Sorry for the incomplete Stacktrace, i have already updated it and Yes, i call tray in Application#OnCreate, does it matter? According to our OS engineer's analysis it should be a file system error caused by illegal replacing system APK file due to Android system protection mechanism. Belows are similar exception logs from different APP arose at the same time:

10-31 19:57:08.024 8348-8348/? W/FileUtils: Failed to chmod(/data/user/0/com.sina.weibo/app_dex): android.system.ErrnoException: chmod failed: EACCES (Permission denied)
         10-31 20:01:32.852 10361-10361/? W/ContextImpl: Failed to ensure /data/user/0/com.qihoo.gameunion/databases: mkdir failed: EACCES (Permission denied)
        10-31 20:11:11.139  6128  6146 W ContextImpl: Failed to ensure /data/user/0/com.qiku.android.memo/databases: mkdir failed: EACCES (Permission denied)
passsy commented 6 years ago

Using tray in Application#onCreate is the only case this ever happens. At least all of the reported crashes where caused when using it there. It works in 99.9% of all cases but on some low end phones, in rare cases, it doesn't.

Because of this we don't recommend using tray in Application#onCreate. Move the logic to an Activity or delay the initialization logic of your application a few seconds. You also wouldn't open a database in Application#onCreate. Keep it fast and non blocking.

There is nothing we can do from our side.