关于
Error:Could not initialize class
org.jetbrains.kotlin.kapt.idea.KaptModelBuilderService
或者
Unable to load class 'kotlin.collections.CollectionsKT' 报错解决问题记录。
导入别人的项目的时候遇到了 Unable to load class 'kotlin.collections.CollectionsKT' 的问题,然后百度跳到了stack overflow 网站,顺着别人的思路顺利的解决了问题,在此记录下,给后来的遇到此坑的人一些提示。
放上链接地址:
android - Unable to load class 'kotlin.collections.CollectionsKT' error when trying to sync gradle - Stack Overflow
https://stackoverflow.com/questions/47418138/unable-to-load-class-kotlin-collections-collectionskt-error-when-trying-to-syn
在留言区,我看到了这样一段描述,英文不好的同学自行翻译也能看懂大概。
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
以上是给我启发的原文内容,简单点说就是 gradle-wrapper.properties 中Grdle的版本和 gradle 版本不一致导致的问题,这么说有些绕口,下面看图指出具体是那两个地方。分别展示在两种目录结构下的位置
这个是我新建的一个正常的project,查看了两处地方的gradle版本配置,然后看下错误的对比。
可以看到跟我正常的项目的Gradle配置确实不一样,就老老实实的改成一样的在看看效果
结果惊奇的发现,居然编译通过了,有点小兴奋,于是乎在这里做下记录,以便后来的同学能给启发的灵感。