androidandroid-studiokotlinandroid-studio-3.1

Android Studio 3.1: Erroneous unresolved references in editor


I'm running Ubuntu 17.10, and I've just updated Android Studio from version 3.0.1 to 3.1. Here's the version information in Help -> About:

Android Studio 3.1
Build #AI-173.4670197, built on March 22, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-37-generic

Unfortunately, while the IDE was able to resolve android-specific references before in my (first ever) Kotlin project, in the new version it appears unable to. Here's a screenshot showing what I mean:

In Android Studio 3.1, it's claiming that core Android functions such as setContentView() don't exist, and keeps prompting me to create an abstract function for it - which I clearly don't want to do. However, if I hit the build button, I get a BUILD SUCCESSFUL in 8s.

Why is my editor doing this, and how I get get Android-related functions and classes to resolve correctly again?


Solution

    1. Exit Studio.
    2. Delete .idea/ (seems to me that's most important), build/, app/build directories.
    3. Start Studio
    4. Set Settings -> Build -> Gradle settings back (last stable Gradle local distribution in my case).
    5. Clean&rebuild project.

    Helps me.