Kotlin版本不匹配,在Meteor Cordova项目中没有进行任何更改。

huangapple go评论90阅读模式
英文:

Kotlin version mismatch in meteor cordova project without any changes

问题

抱歉,代码部分不需要翻译。以下是您要求的翻译内容:

我有一个Meteor 2.9.0(cordova-android 10)项目,上周在我的Windows 10机器上成功构建,一切都正常。但是从那时起,我没有做任何更改,但现在它无法构建,我已经没有办法修复它了。

我收到关于使用不兼容版本的Kotlin编译的模块的错误消息。主要来自PushPlugin,但这是一个我已经硬编码到特定的Git提交的插件,因此不可能有任何更改。
错误信息:

> Task :app:compileDebugKotlin FAILED
w: 在类路径中的运行时JAR文件应该具有相同的版本。在类路径中找到了这些文件:
    C:/Users/Meteor/.gradle/caches/transforms-3/cc5cc74c45c7cc5e76733fe8278ba926/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (版本1.5)
    C:/Users/Meteor/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar (版本1.7)
    C:/Users/Meteor/.gradle/caches/transforms-3/eda4e3aecc1ddb0771d71f6ab843e15d/transformed/jetified-kotlin-stdlib-common-1.7.10.jar (版本1.7)
w: 在类路径中的一些运行时JAR文件具有不兼容的版本。考虑从类路径中删除它们
e: 在依赖项中找到不兼容的类。从类路径中删除它们或使用'-Xskip-metadata-version-check'来抑制错误
e: C:/Users/Meteor/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/META-INF/annotation.kotlin_module: 模块是用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.7.1,预期版本为1.5.1。
e: C:/Users/Meteor/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar!/META-INF/kotlin-stdlib.kotlin_module: 模块是用不兼容的Kotlin版本编译的。
其元数据的二进制版本为1.7.1,预期版本为1.5.1。
e: C:/Users/Meteor/.gradle/caches/transforms-3/eda4e3aecc1ddb0771d71f6ab843e15d/transformed/jetified-kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: 模块是用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.7.1,预期版本为1.5.1。
e: D:\GIT\meteor-app\.meteor\local\cordova-build\platforms\android\app\src\main\java\com\adobe\phonegap\push\BackgroundActionButtonHandler.kt:(14,2):类'kotlin.Suppress'是用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.7.1,预期版本为1.5.1。
该类从C:/Users/Meteor/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar!/kotlin/Suppress.class加载

我尝试更新了我PC上安装的Gradle版本(7.3.1)到7.6.1,清除了.gradle/caches目录,以及删除了整个.gradle目录。我卸载了所有的Android SDK,然后在Android Studio中重新安装它们。我的应用程序目标SDK为31。

我正在使用Java JDK 11.0.17,Gradle 7.3.1,但我认为Meteor / Cordova使用它自己的Gradle版本,因为我看到日志中包含了gradle 7.1.1。我搜索了整个项目(包括Cordova构建)中硬编码的Kotlin版本,但我找到的唯一内容是:

android.json:
"xml": "<preference name=\"GradlePluginKotlinVersion\" value=\"1.5.20\" />"

cdv-gradle-config.json:
"KOTLIN_VERSION": "1.5.20"

plugins/@havesource/cordova-plugin-push/plugin.xml:
<preference name="GradlePluginKotlinVersion" value="1.5.20" />

所以一切都匹配,但不知何故它抱怨Kotlin 1.7.1...
我已经对此感到厌烦,这不是我第一次因为未经触碰而花费数小时来解决破坏Android构建的各种问题,Android相关的东西在不触碰的情况下就会神奇地消失,东西停止工作...与此相比,为iOS构建是一种乐趣。

我知道有大量类似的问题,但它们都涉及修改项目中的Gradle设置,而在这种情况下,我无法这样做,因为所有操作都由Cordova和它的插件完成。而且直到现在一切都正常!

英文:

I have a Meteor 2.9.0 (cordova-android 10) project that was working all fine and I could build it on my Windows 10 machine successfully last week. Nothing changed since then from my side yet it now fails and I'm running out of ideas how to fix it.

I'm getting errors about modules being compiled with an incompatible version of Kotlin. Mainly from the PushPlugin, but that's a plugin that I have hardcoded to a specific git commit so it's impossible that anything changed there.
Errors:

> Task :app:compileDebugKotlin FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    C:/Users/Meteor/.gradle/caches/transforms-3/cc5cc74c45c7cc5e76733fe8278ba926/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (version 1.5)
    C:/Users/Meteor/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar (version 1.7)
    C:/Users/Meteor/.gradle/caches/transforms-3/eda4e3aecc1ddb0771d71f6ab843e15d/transformed/jetified-kotlin-stdlib-common-1.7.10.jar (version 1.7)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/Meteor/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: C:/Users/Meteor/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible 
version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: C:/Users/Meteor/.gradle/caches/transforms-3/eda4e3aecc1ddb0771d71f6ab843e15d/transformed/jetified-kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: D:\GIT\meteor-app\.meteor\local\cordova-build\platforms\android\app\src\main\java\com\adobe\phonegap\push\BackgroundActionButtonHandler.kt: (14, 2): Class 'kotlin.Suppress' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from C:/Users/Meteor/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar!/kotlin/Suppress.class

I have tried updating my gradle version installed on PC (7.3.1) to 7.6.1, clearing the .gradle/caches directory as well as removing the whole .gradle directory.
I un-installed all the Android SDK's and re-installed them again in Android Studio. My app targets sdk 31.

I'm running Java JDK 11.0.17, gradle 7.3.1 but I think meteor/cordova uses it's own gradle version since I saw logs containing gradle 7.1.1. I have searched my entire project (cordova build included) for hardcoded kotlin versions, and all I could find is:

android.json:
"xml": "<preference name=\"GradlePluginKotlinVersion\" value=\"1.5.20\" />",

cdv-gradle-config.json:
"KOTLIN_VERSION": "1.5.20",

plugins/@havesource/cordova-plugin-push/plugin.xml:
<preference name="GradlePluginKotlinVersion" value="1.5.20" />

So everything matches, yet somehow it complains about kotlin 1.7.1...
I'm already tired of this, it's not the first time I'm struggling for hours with random stuff breaking the android build without me touching anything, Android related things magically disappear from the env variables, things stop working... building for iOS is a pleasure compared to this.

I know there is a ton of similar questions, but all of them refer to modifying gradle settings in the project which I cannot do in this case, because it is all done by cordova and it's plugins. And it worked fine until now!

答案1

得分: 2

我自己找到了答案。看来我不是唯一受困扰的人。对其他人来说,似乎也自动发生了一些改变,尽管没有进行任何更改,构建停止工作。请参见此处:https://github.com/havesource/cordova-plugin-push/issues/218

将 Cordova 首选项添加到使用更高版本的 Kotlin 修复了此问题,但我想知道发生了什么,是谁引起了这个问题。

英文:

I have found an answer myself. Seems I'm not the only one haunted. Something has auto-magically changed for others too and building stopped working despite no changes being made. See here: https://github.com/havesource/cordova-plugin-push/issues/218

Adding the cordova preference to use the higher Kotlin version fixed this, but I wonder what happened and who caused this

huangapple
  • 本文由 发表于 2023年3月15日 18:59:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743807.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定