Unresolved reference: Application


#1

So i try to extend the Application class and get this error. This is how im trying to do it in java and it works:

public class MainApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    }
}

Then i convert it to Kotlin:

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
    }
}

And here i get unresolved reference: Application.

Seems like something is buggy.

My kotlin version on the project is 1.2.60


#2

Stupid question but is it imported?


#3

There was no option to import if, only to create a class Application.


#4

You are definitely speaking on different languages. @pie_flavor is talking about class imports at the beginning of each file.


#5

no, i think they speak the same language. @lxknvlk is, i assume speaking about the intellij intention to fix the error of the unknown class. and there seems to be only a fix available to create the class.
But You could check the import of the Application class in your java code and copy that to your kotlin file. if this does not fix the problem, then your kotlin file somehow does not see the same classpath dependencies than your java files.
do both files live in the same intellij module?
if not check the dependencies of the modules in the intellij project structure.