So, I wanted to implement a simple database handler class for my Android Studio project with Kotlin. Little did I know when I eye-rolled towards my "what even is kotlin" developer mates, that this hipster choice would lead me to lengthy damnation.
I decided to start out by copy-pasting the code Google suggests for a DB Helper utilizing the SQLiteOpenHelper
class.
Naturally, I started getting this unreasonable error
for each of the closing brackets }
in 3 different methods containing what looked like perfectly valid syntax.
Of course, I spent over a day checking every single piece of annoying Gradle build property that seems to be there only to increase the chances of something being off, as if it were a perfectly designed developer-Limbo build system from Hell. But every little check was to no avail, as I had no build errors and the "Expecting member" errors kept showing up.
Decided not to quit however, I even attempted to change my implementation to use the more Kotlin-friendly anko.db
route, full code below.
package com.example.john.myapplication
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import org.jetbrains.anko.db.*
class DBHandler(context: Context) : ManagedSQLiteOpenHelper(context, "POIEncounters", null, 1) {
override fun onCreate(db: SQLiteDatabase?) {
db?.createTable("Encounter", true, "id" to INTEGER + PRIMARY_KEY + UNIQUE, "Name" to TEXT)
}
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
db?.dropTable("Encounter", true)
}
override fun onDowngrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
onUpgrade(db, oldVersion, newVersion)
}
}
As Divine Order dictates in the Developer Limbo, there was no change at all. Every time I click Build
I am fooled by the syntax checker's underhanded reassurances, as the compiler denies my salvation. Even more amazingly. the errors persist even if I comment-out the entire bodies of the overridden methods.
At this point I am so beyond despair that I have fallen to the lowest level of the abyss: rejecting my ego and asking for help.