Android/Kotlin: Error: “Expecting a top level declaration > Task :app:buildInfoGeneratorDebug”

I try to write a class to manage a SQLite DB, but I have the error message “Expecting a top level declaration > Task :app:buildInfoGeneratorDebug”.

   package com.xexxxwxxxxs.GMP

    import android.database.sqlite.SQLiteDatabase
    import android.database.sqlite.SQLiteOpenHelper
    import android.content.Context
    import android.content.ContentValues

    class DBHandler(context: Context, name: String?, factory: SQLiteDatabase.CursorFactory?, version: Int) : SQLiteOpenHelper(context, DATABASE_NAME, factory, DATABASE_VERSION)
        override fun onCreate(db: SQLiteDatabase)


        override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int)


        companion object
            private val DATABASE_VERSION = 1
            private val DATABASE_NAME = "GMP.db"

Do you have any ideas?

Thanks in advance

Enquirer: ?lostA


Solution #1:

I just delete last curly brace and write it again. It’s working 🙂

Respondent: Ensar Bayhan

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.