相互矛盾的喷射科特林反射依赖 [英] Conflicting jetified-kotlin-reflect dependency

查看:348
本文介绍了相互矛盾的喷射科特林反射依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建Android项目时,会收到以下消息:

When I build my Android project, I get the following message:

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/janek/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.10/4d147bf43060dc43d61b096e24da1e67dfe0c032/kotlin-stdlib-jdk7-1.3.10.jar (version 1.3)
    /home/janek/.gradle/caches/transforms-1/files-1.1/kotlin-reflect-1.0.6.jar/beba9d201a205f30041b70982540014d/jetified-kotlin-reflect-1.0.6.jar (version 1.0)
    /home/janek/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.11/4cbc5922a54376018307a731162ccaf3ef851a39/kotlin-stdlib-1.3.11.jar (version 1.3)
    /home/janek/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.11/d8b8e746e279f1c4f5e08bc14a96b82e6bb1de02/kotlin-stdlib-common-1.3.11.jar (version 1.3)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

但是我不知道为什么jetified-kotlin-reflect甚至在其中,因为它不是依赖项,甚至没有出现在androidDependencies中.

But I have no idea why jetified-kotlin-reflect is even in there, since It isn't a dependency and does not even appear in androidDependencies.

您知道它的来源或如何解决此错误吗?

Do you know where it comes from or how I can resolve this error?

推荐答案

如果您使用

I guess the kotlin plugin will automatically add the kotlin-relfection.jar if you use reflection features like class literal syntax.

在Java平台上,使用反射功能所需的运行时组件作为单独的JAR文件(kotlin-reflect.jar)分发.这样做是为了减少不使用反射功能的应用程序所需的运行时库大小.如果您确实使用反射,请确保将.jar文件添加到项目的类路径中.

On the Java platform, the runtime component required for using the reflection features is distributed as a separate JAR file (kotlin-reflect.jar). This is done to reduce the required size of the runtime library for applications that do not use reflection features. If you do use reflection, please make sure that the .jar file is added to the classpath of your project.

我通过明确添加来修正警告

I fixed the warnings by explicitly adding

implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

到我的build.gradle.

to my build.gradle.

这篇关于相互矛盾的喷射科特林反射依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆