Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.kt files not recognized in Android Studio

I opened my Studio today and Android Studio didn't recognize Kotlin files. .kt files started showing up as just an ordinary file. I checked my Plugins and I still have the Kotlin plugin. I tried uninstalling and installing it again. But no use.

I tried building my building my project from Terminal and it works fine. But Android studio doesn't understand Kotlin files.


Configuration:

Android Studio 3.1

Kotlin 1.2.41

OS: MacOS Sierra

like image 644
Henry Avatar asked Sep 03 '25 03:09

Henry


2 Answers

Go to Library/Preferences and delete the AndroidStudio3.1 folder. This is the config directory for my Android Studio.

Once deleted, I started Studio again, and the config was created fresh. Now everything worked perfectly.

like image 50
Henry Avatar answered Sep 06 '25 19:09

Henry


Lets say, I'm creating new file named HomeFragment, and AndroidStudio didn't recognize it as kotlin file. Fix Steps:

  1. AndroidStudio -> Preferences -> Editor -> File Types
  2. Click on File type auto-detected by file content, make sure this sections doesn't have prefill File name patterns - HomeFragment, if it does, delete it.
  3. Click on Kotlin, make sure it has "*.kt"
  4. Click on Text, make sure it doesnt have "*.kt"

once done, click Apply and OK

Step 2 Step 3 Step 4

like image 45
Gideon Steven Avatar answered Sep 06 '25 19:09

Gideon Steven