Im trying to add _boofcv-core_ library to my Android project. _boofcv-android_ works fine but _boofcv-core_ generates the following error:java.lang.RuntimeException:模块中的重复类com.google.protobuf.AbstractMessageLite (com.google.m trying to add _boofcv-core_ library to my Android project. _boofcv-android_ works fine but _boofcv-core_ generates the following error:java.lang.RuntimeException:protobuf-java:3.17.3)和protobuf 3.14.0.jar
build.gradle的代码
...
configurations {
// compile.exclude group: 'com.google.protobuf' // when uncommented, causes other errors
all*.exclude group: "xmlpull", module: "xmlpull"
all*.exclude group: "org.apache.commons", module: "commons-compress"
all*.exclude group: "com.thoughtworks.xstream", module: "commons-compress"
}
dependencies {
['boofcv-android', 'boofcv-core'].each {
String a -> implementation group: 'org.boofcv', name: a, version: '0.37'
}
...发布于 2022-11-08 14:01:00
解决:protobuf-java(boofcv-core中的依赖)和protobuf-javalite(firebase中的依赖)不能共存- 详细解释。在生成依赖树(./gradlew app:dependencies)之后,我注意到只有boofcv-geo和boofcv-recognition ( boofcv-core中的库-参见链接)依赖于protobuf-java。我不需要这两个库,所以我将它们排除在编译之外。在app/build.gradle上添加:
...
configurations {
compile.exclude group: 'org.boofcv',module: 'boofcv-recognition' //<-- added
compile.exclude group: 'org.boofcv',module: 'boofcv-geo' //<-- added
all*.exclude group: "xmlpull", module: "xmlpull"
all*.exclude group: "org.apache.commons", module: "commons-compress"
all*.exclude group: "com.thoughtworks.xstream", module: "commons-compress"
}
...然后错误就消失了。
https://stackoverflow.com/questions/74357686
复制相似问题