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

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

我尝试编写 class 来管理 SQLite 数据库,但我收到错误消息 "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"
        }
    } 

你有什么想法吗?

提前致谢

我只是把最后一个花括号删了重新写。它正在工作:)

我也遇到了同样的情况,你只需要在末尾删除一个自动生成的额外花括号,然后就可以了。