Erik
Erik

Reputation: 1331

Unable to load class 'kotlin.collections.CollectionsKT' error when trying to sync gradle

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?

Upvotes: 6

Views: 6142

Answers (3)

drc
drc

Reputation: 275

Proguard obfuscation will also do this; you may need to set minifyEnabled false in your build.gradle

Upvotes: 1

Bhargav Bandla
Bhargav Bandla

Reputation: 1

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.

Upvotes: 0

Phileo99
Phileo99

Reputation: 5659

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.

Upvotes: 4

Related Questions