Unable to load class 'kotlin.collections.Colle

2019-06-23 23:13发布

问题:

Today I started to get the error Unable to load class 'kotlin.collections.CollectionsKT' (as show in this image) every time I try to gradle sync my project. I couldn't find anything on this error and the only solution seems to be to disable kotlin plugin on Intellij. Some of my projects doesn't have kotlin, but others have (the ones without kotlin also throw this error when trying to sync), so that isn't viable option.

Does anyone have any clue on what it could be?

回答1:

Strange, I started experiencing this issue today as well. In my case, I did not need to disable the Kotlin plugin, but I did need to upgrade the Gradle distribution (in the gradle-wrapper.properties) from 3.3 to 4.1 Someone logged a ticket in the issue tracker for this. If you could provide your feedback there and vote up that issue, it may help to get this resolved quicker.



回答2:

I had the same problem when I was trying out a sample project on GitHub. I had no idea why this is happening, later I realised that the gradle version in gradle-wrapper.properties and the gradle version installed on my machine are different. So I just updated the gradle-wrapper.properties to take latest gradle version installed. Everything built smoothly.

You may also have a mismatch in gradle build tools version in build.gradle file. Update that as well if required. This is how my build.gradle look like after updating

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}

Hope this helps.