gradle JGit导致开箱即用的重复类错误

sbtkgmzw  于 2023-04-30  发布在  Git
关注(0)|答案(1)|浏览(476)

尝试将JGit集成到Android项目中,并获得大量重复的类错误,这些错误都来自JGit传递依赖:
重复类检测显示:

- org/apache/sshd/common/util/closeable/SequentialCloseable.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/closeable/SimpleCloseable.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/functors/Int2IntFunction.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/functors/UnaryEquator.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/helper/LazyIterablesConcatenator$1.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/helper/LazyIterablesConcatenator.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/helper/LazyMatchingTypeIterable.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/helper/LazyMatchingTypeIterator.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]
    - org/apache/sshd/common/util/io/CloseableEmptyInputStream.class is in [sshd-osgi-2.7.0.jar, sshd-common-2.7.0.jar]

都是sshd-osgi-27.0.jar AND sshd-common-2.在运行gradle dependencies时,7.0.jar来自org.eclipse.jgit:org.eclipse.jgit.ssh.apache

|    +--- org.eclipse.jgit:org.eclipse.jgit.ssh.apache:5.13.1.202206130422-r
    |    |    +--- org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r (*)
    |    |    +--- org.apache.sshd:sshd-osgi:2.7.0
    |    |    |    +--- org.slf4j:slf4j-api:1.7.30
    |    |    |    \--- org.slf4j:jcl-over-slf4j:1.7.30
    |    |    |         \--- org.slf4j:slf4j-api:1.7.30
    |    |    +--- org.apache.sshd:sshd-sftp:2.7.0
    |    |    |    +--- org.apache.sshd:sshd-core:2.7.0
    |    |    |    |    +--- org.apache.sshd:sshd-common:2.7.0

我错过了什么,或者这个相当常用的包实际上在其依赖项中有重复的类,这些类在Android平台中打破了它的使用??

hsvhsicv

hsvhsicv1#

JGit的依赖项应该调整为不包含不同jar中的重复类。
作为一种解决方法,您可以尝试通过build.gradle中的以下内容排除org.apache.sshd:sshd-common:2.7.0上的重复传递依赖项:

configurations {
    all*.exclude group: 'org.apache.sshd', module: 'sshd-common'
}

相关问题