Search code examples
androidandroid-studiokotlinintellij-idea

How to resume a stuck code analysis in Android Studio?


I recently noticed a behaviour, that the default code analysis does not finish anymore in one of my android projects, in particular in kotlin files - unfortunately without an error message. With a stuck analysis I am not able to identify errors in my code anymore and basic stuff like autocompletion does not work, which makes it unable to work.

In the top right corner of the opened file I constantly get Analyzing...

analyzing

I already tried restarting Android Studio, invalidating its cache, deleting and cloning my project again, rebooting and deleting all kind of gradle and Android Studio cache files but without success.


Solution

  • I finally got it working again with the help of the idea.log file, which can be found via Help > Show Log in Explorer in Android Studio.

    The log stated an Exception while analyzing expression at different locations in my files, caused by java.lang.IllegalStateException: @NotNull method org/jetbrains/kotlin/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null.

    Since it looked like a Kotlin related issue, I upgraded org.jetbrains.kotlin:kotlin-stdlib-jdk7 in my build.gradle from 1.4.10 to 1.5.10 and it worked instantly again. I hope the info helps anyone!