Gradle 传递依赖版本冲突
Gradle TransitiveDependency Version Conflict
我一直在为使用 PDFBox 的现有项目实施扩展 pdf 创作 API。
为了使用 PDFBox,我需要在 build.gradle:
中包含以下依赖项
implementation('com.tom_roush:pdfbox-android:1.8.10.0')
现有项目使用的依赖项之一是用于加密组件的 spongycastle:
implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0'
所以我首先将两个依赖项都包含到我的 build.gradle 文件中,并且
试图构建应用程序。这是我收到的异常:
Program type already present:
org.spongycastle.cert.CertRuntimeException Message{kind=ERROR,
text=Program type already present:
org.spongycastle.cert.CertRuntimeException, sources=[Unknown source
file], tool name=Optional.of(D8)}
我假设此问题是由于 pdfbox 的传递依赖性导致的版本冲突引起的,具体如下:
我尝试使用 build.gradle:
中的依赖项排除来解决问题
implementation('com.tom_roush:pdfbox-android:1.8.10.0'){
exclude group:'com.madgag.spongycastle'
}
因为据我所知,我没有在我的 pdfbox 实现中直接使用加密方面。
你可以试试force predefined versions
configurations.all {
resolutionStrategy {
failOnVersionConflict()
force 'com.magdag.spongycastle:prov:1.58.0.0'
force 'com.magdag.spongycastle:core:1.58.0.0'
}
}
它也可能由于版本而改变库。可能是已删除或重命名的文件。也可以尝试强制1.54.0.0版本
非常感谢 - 我已经能够使用不同的方法解决问题。
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module('com.madgag.spongycastle:pkix:1.54.0.0') with module('com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0')
}
}
这解决了我的问题。
我一直在为使用 PDFBox 的现有项目实施扩展 pdf 创作 API。 为了使用 PDFBox,我需要在 build.gradle:
中包含以下依赖项implementation('com.tom_roush:pdfbox-android:1.8.10.0')
现有项目使用的依赖项之一是用于加密组件的 spongycastle:
implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0'
所以我首先将两个依赖项都包含到我的 build.gradle 文件中,并且 试图构建应用程序。这是我收到的异常:
Program type already present: org.spongycastle.cert.CertRuntimeException Message{kind=ERROR, text=Program type already present: org.spongycastle.cert.CertRuntimeException, sources=[Unknown source file], tool name=Optional.of(D8)}
我假设此问题是由于 pdfbox 的传递依赖性导致的版本冲突引起的,具体如下:
我尝试使用 build.gradle:
中的依赖项排除来解决问题implementation('com.tom_roush:pdfbox-android:1.8.10.0'){
exclude group:'com.madgag.spongycastle'
}
因为据我所知,我没有在我的 pdfbox 实现中直接使用加密方面。
你可以试试force predefined versions
configurations.all {
resolutionStrategy {
failOnVersionConflict()
force 'com.magdag.spongycastle:prov:1.58.0.0'
force 'com.magdag.spongycastle:core:1.58.0.0'
}
}
它也可能由于版本而改变库。可能是已删除或重命名的文件。也可以尝试强制1.54.0.0版本
非常感谢 - 我已经能够使用不同的方法解决问题。
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module('com.madgag.spongycastle:pkix:1.54.0.0') with module('com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0')
}
}
这解决了我的问题。