Search code examples
androidandroid-studiokotlintype-mismatch

Android Studio shows type mismatch error for compilable kotlin code


In our team, there are two groups of members.

For the first group, Android Studio offers to simplify the code like below and transform redundant declaration of types to lambdas.

For the second group, Android Studio marks the simplified code as incorrect with a type mismatch compilation error. But the code still compilable.

But no one knows what settings to tweak for the second group to join the first group.

Does anyone know, what settings are responsible for this behavior? enter image description hereenter image description here


Solution

  • Updating Studio to the most recent version (currently 4.1.2) caused Studio to offer to update Kotlin-plugin to 1.4.30 version, which, I believe, solved the problem.

    If I'm not mistaking, there was no option to update Kotlin-plugin to 1.4.30 in Android Studio 4.0.2, at least Studio didn't offer to do so and there was no Install-button in Configure Kotlin Plugin Updates settings section.

    But I intentionally used a bit outdated version, because AndroidStudio 4.1.2 is buggy as hell.

    UPD

    Because recent Android Studio has a huge bunch of bugs like this or this making it almost impossible to use, there is no option for me to stay on 4.1.2 until these bugs are fixed.

    So I downgraded studio to 4.0.2 again, but installed Kotlin plugin of 1.4.21 version manually. You can do so by downloading it from official JetBrains site and following the screenshot instruction below.

    So now I have stable Android Studio and recent Kotlin-plugin which solves type-mismatch problem.

    enter image description here