Android/Kotlin: Error: "Expecting a top level declaration > Task :app:buildInfoGeneratorDebug"
36,045
Solution 1
I just delete the last curly brace and write it again. It's working :)
Solution 2
The same happened to me, you just need to remove an auto-generated extra curly bracket at the end, then it works.
Comments
-
ΩlostA over 2 years
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
-
ΩlostA about 5 yearsYou just killed me :D It works. Incredible... It seems that there is a invisble character at the end.
-
pallav bohara almost 4 yearsIn my case there was an extra closing braces
-
Syed Arsalan Kazmi almost 3 yearsJust when I though that there is no place for black magic in the coding. hehe. Thanks.
-
Richard Kirk almost 2 yearsI had a slightly fancier version: I had to delete the last three brackets and put them back in again.