Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio does not resolve classes written in Kotlin (.kt) in the IDE but compiles fine

I'm starting to work on an existing project which uses standard java and partially Kotlin for some classes.

PROBLEM:

The projects compiles and runs fine, but when viewing the code in Android Studio, the classes written in kotlin show unresolved in the ide.


UserConfigActivity.kt (Class written in Kotlin)

class UserConfigActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_user_config)
        setSupportActionBar(toolbar)

Unresolved when referenced/used in standard java class (although compiles and runs fine):

enter image description here


When opening the .kt files directly in android studio it prompts that a plugin is found as follows:

enter image description here

But when i click on Install Plugins, nothing happens (no install or change in situation). Prompt reappears next time i open another .kt file.


QUESTIONS:

  1. How to resolve the Cannot resolve symbol for classes written in Kotlin?
  2. How to install the plugin which is offered in prompt but does not install when clicking Install Plugins?

I'm on Android Studio 2.1.1.

like image 207
AndroidMechanic - Viral Patel Avatar asked Sep 18 '25 06:09

AndroidMechanic - Viral Patel


1 Answers

To install the Kotlin plugin, open the Settings dialog, select the "Plugins" node, press the "Install JetBrains plugin" button and select "Kotlin" from the list. Then restart the IDE.

like image 125
yole Avatar answered Sep 19 '25 20:09

yole