caarmen / poet-assistant

Android app with rhyming dictionary, thesaurus, and dictionary, with text-to-speech functionality to read your poem.
Other
83 stars 11 forks source link

Exceptions preventing the app from working, on ICS #133

Closed caarmen closed 6 years ago

caarmen commented 6 years ago
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading: java.lang.ClassCastException: android.database.sqlite.SQLiteCursor cannot be cast to java.io.Closeable
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at ca.rmen.android.poetassistant.main.dictionaries.rt.Rhymer.getWordVariants(Rhymer.kt:44)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at ca.rmen.rhymer.Rhymer.getRhymingWords(Rhymer.java:52)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at ca.rmen.android.poetassistant.main.dictionaries.rt.RhymerLiveData.loadInBackground(RhymerLiveData.kt:92)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at ca.rmen.android.poetassistant.main.dictionaries.rt.RhymerLiveData.loadInBackground(RhymerLiveData.kt:38)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at ca.rmen.android.poetassistant.main.dictionaries.ResultListLiveData$onActive$1.invoke(ResultListLiveData.kt:35)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at ca.rmen.android.poetassistant.CoroutineThreading$execute$1$task$1.doResume(CoroutineThreading.kt:39)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at kotlinx.coroutines.experimental.DispatchTask.run(CoroutineDispatcher.kt:129)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-29 06:37:16.695  1710  1710 V PoetAssistant/CoroutineThreading:  at java.lang.Thread.run(Thread.java:856)

https://stackoverflow.com/questions/39430179/kotlin-closable-and-sqlitedatabase-on-android

caarmen commented 6 years ago

Cursor extends Closeable starting from jellybean. time to change the minsdk

anonym24 commented 5 years ago

So to support older Android versions I have to use .use { ... } only from Jellybean?

val cursor = ...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    cursor.use {
        while (it.moveToNext()) {
            //
        }
    }
} else {
    while (cursor.moveToNext()) {
        //
    }
    cursor.close()
}

Something like this?

I have users running Android 4.0.3-4.0.4 and Crashlytics (or Google Console) for some of these devices reports the next exception in funcitons where I use Cursor and SQLiteOpenHelper

Caused by java.lang.ClassCastException
cannot be cast to java.io.Closeable