Kotlin 库 'classes.jar' 的格式不受支持。请更新库或插件

Kotlin library 'classes.jar' has an unsupported format. Please update the library or the plugin

此消息出现在项目同步中。

我尝试清理并重建项目,但没有成功。

我使用的是最新的插件版本 0.12.275,"org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.213" 和 "org.jetbrains.kotlin:kotlin-stdlib:0.12.213"

我已经尝试使用稳定版本 0.12.200 的插件和库,但我得到了同样的错误。

我正在使用 Android Studio AI-141.1972460(金丝雀频道)。

这是新插件版本的 Kotlin 错误

看起来问题出在我的 *.aar 库中,它包含在项目中 - 它是用旧版本的 Kotlin 编译的。我已将库升级到最新的 Kotlin 版本,现在可以使用了。

@ookami.kb

提到的更新库解决了这个问题

关于错误信息...

当 Kotlin 创建的 class 文件的 ABI 版本号与 Kotlin 编译器使用的预期版本号不匹配时,会出现 "unsupported format" 错误。这不再是 Kotlin 1.0 Betas 的问题,因为 ABI 编号不会在 1.0 中再次更改。但是,在 1.0 候选发布版中将进行一次强制重新编译,以确保没有旧的编译器错误影响库或代码,并且一切都重建干净。之后就不会再有这样的问题了。

因此,如果库不是具有相同 ABI 的最新版本,或者点击了最后一个“1.0 重新编译”,您可能 运行 会出现类似的错误。解决方案总是找到更新的库。

Kotlin 1.0 Beta 4 announcement "What's Next" 部分中有更多相关信息:

After the Beta period is over, there will an RC and then 1.0.

We would really like to make sure that no code compiled with pre-release versions of Kotlin are kept around after 1.0, so the RC compiler will force recompilation of all the old code. We will coordinate with library maintainers outside JetBrains to make sure that all the widely-used libraries will be recompiled in time.

We’ll also take the opportunity to remove some legacy at this point:

  • remove all the deprecations that we have accumulated in the process of evolving our libraries,
  • remove all the deprecations from the generated code (you might not have heard of those, but they exist!),
  • get rid of some legacy bytecode peculiarities that were found during the beta,
  • move some of the stdlib code around so that the packages there have more structure.

After that point, the only compatible changes to the standard library are deprecations and additions (this does not include reflection APIs). We are running an open review for the library API to make sure we haven’t missed anything important.