quickstart-android: DatabaseObjectNotClosedException thrown on 9.8.0

  • Android device: Moto G (2nd Gen)
  • Android OS version: Android 6.0
  • Google Play Services version: 3.0.0
  • Firebase/Play Services SDK version: 9.8.0

Hi guys! I’m trying to use the latest version of the messaging library but I’m getting an DatabaseObjectNotClosedException exception and it says that the google_app_measurement_local.db file is closed. The funny thing is that if I change the version of the library to, lets say 9.6.1, this doesn’t happen and the notifications arrived successfully.

My gradle file is:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'

    compile 'com.google.firebase:firebase-database:9.8.0'
    compile 'com.google.firebase:firebase-storage:9.8.0'
    compile 'com.google.firebase:firebase-auth:9.8.0'
    compile 'com.google.firebase:firebase-messaging:9.8.0'

    ... (other libraries)
}

(I’m trying to have support for both, GCM and FCM for now, just in case our FCM server breaks down we need a backup)

I’ve been looking on SO or similar and haven’t found a solution to this. Some links:

So basically, my questions are:

  • Why does this happen using the latest version and not the previous one?
  • Is it feasible to have both, GCM and FCM in my app?

Thanks in advance

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 34 (8 by maintainers)

Most upvoted comments

same issue on 10.2.4 . Is there an estimate, when it will be fixed?

Still seeing this in 10.2.0 whenever an activity or fragment is destroyed. 3-01 19:58:49.070 24205-24216/com.theclinician.oneclinic E/StrictMode: Finalizing a Cursor that has not been deactivated or closed. database = /data/user/0/com.theclinician.oneclinic/databases/google_app_measurement_local.db, table = null, query = select count(1) from messages android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:98) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:50) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source) 03-01 19:59:16.932 24205-24216/com.theclinician.oneclinic E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at android.database.CursorWindow.<init>(CursorWindow.java:111) at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219) at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source) 03-01 19:59:16.933 24205-24216/com.theclinician.oneclinic E/StrictMode: Finalizing a Cursor that has not been deactivated or closed. database = /data/user/0/com.theclinician.oneclinic/databases/google_app_measurement_local.db, table = null, query = select count(1) from messages android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:98) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:50) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source) 03-01 19:59:23.901 24205-24216/com.theclinician.oneclinic E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at android.database.CursorWindow.<init>(CursorWindow.java:111) at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219) at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source) 03-01 19:59:23.902 24205-24216/com.theclinician.oneclinic E/StrictMode: Finalizing a Cursor that has not been deactivated or closed. database = /data/user/0/com.theclinician.oneclinic/databases/google_app_measurement_local.db, table = null, query = select count(1) from messages android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:98) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:50) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source) 03-01 19:59:33.570 24205-24216/com.theclinician.oneclinic E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at android.database.CursorWindow.<init>(CursorWindow.java:111) at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219) at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source) 03-01 19:59:33.570 24205-24216/com.theclinician.oneclinic E/StrictMode: Finalizing a Cursor that has not been deactivated or closed. database = /data/user/0/com.theclinician.oneclinic/databases/google_app_measurement_local.db, table = null, query = select count(1) from messages android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:98) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:50) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzatv.zza(Unknown Source) at com.google.android.gms.internal.zzaul.zzc(Unknown Source) at com.google.android.gms.internal.zzauj.zzb(Unknown Source) at com.google.android.gms.internal.zzauj.zza(Unknown Source) at com.google.android.gms.internal.zzauj$8.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at com.google.android.gms.internal.zzaud$zzd.run(Unknown Source)

Same issue on 10.2.6. When this issue will be fixed?

Seeing this exception on 10.0.1, when enabling StrictMode. No crash. Is there an issue opened on Firebase?

This issue is still known to be present in 10.0.1.

When a release goes out that contains the fix I will update this issue.

@joshfriend I don’t use it. My stack trace is Exception android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. android.database.CursorWindow.<init> (CursorWindow.java:112) android.database.CursorWindow.<init> (CursorWindow.java:100) android.database.AbstractWindowedCursor.clearOrCreateWindow (AbstractWindowedCursor.java:198) android.database.sqlite.SQLiteCursor.clearOrCreateWindow (SQLiteCursor.java:364) android.database.sqlite.SQLiteCursor.fillWindow (SQLiteCursor.java:162) android.database.sqlite.SQLiteCursor.getCount (SQLiteCursor.java:156) android.database.AbstractCursor.moveToPosition (AbstractCursor.java:161) android.database.AbstractCursor.move (AbstractCursor.java:197) bre.b (bre.java:152) bru.run (bru.java:3124) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1076) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:569) java.lang.Thread.run (Thread.java:856)

While I don’t use SQLite in the project at all

Hey all. I just heard back from the team and apparently the fix for this got delayed but will be included in the next SDK release, which should be in a matter of weeks. I will keep this issue closed until it comes out, thank you all for your patience.

This issue was reported 5 months ago. Please, we need a fix soon. =(

Thanks @samtstern. Any ETA on it? Unfortunately I have shipped a release with this and this only showed up in logs afterwards. It seems that this issue is causing the biggest problems on Android 6.0.1 phones for some reason?

Hi all. We have looked at this and there will be a fix in a future release. Right now there are no known workarounds for the broken versions, but I will update here if there are.