Java 和 Kotlin混编的项目,一直好好的,可以正常编译运行。
然而突然有一天,就运行不起来了。
报错如下:
Execution failed for task ':app:kaptGenerateStubsOfficialDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Could not download commons-lang3.jar (org.apache.commons:commons-lang3:3.4)
> Could not get resource 'http://jcenter.bintray.com/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar'.
> Could not GET 'http://jcenter.bintray.com/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar'.
> Remote host closed connection during handshake
真是莫名其妙了,之前明明是正常运行的。
好吧,找解决办法,有说是因为Kotlin版本问题。
我在build.gradle中使用的是:ext.kotlin_version = '1.3.0'
再看看android studio中kotlin插件的版本
可以看到两个版本确实不一样。那就把build.gradle中的改为“1.3.31”。
编译,运行,成功!!!