I`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: Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-3.17.3.jar (com.google.protobuf:protobuf-java:3.17.3) and protobuf-javalite-3.14.0.jar (com.google.protobuf:protobuf-javalite:3.14.0)...
The code at 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'
}
...
Solved:
protobuf-java
(dependency insideboofcv-core
) andprotobuf-javalite
(dependency insidefirebase
) cant exist together- full explanation here. After generating a dependency tree(./gradlew app:dependencies
), I noticed that onlyboofcv-geo
andboofcv-recognition
(libraries insideboofcv-core
- see link) depend onprotobuf-java
. I have no need in these 2 libraries so I excluded them from compilation. At app/build.gradle, add:And then the error disappears.