Android Gradle conflict with Google firebase-firestore: protobuf-lite nested dependency
See original GitHub issueDescribe the bug I am attempting to test Capillary in a simple Android app (on device), but during the gradle build process I am getting “Error: Program type already present: com.google.protobuf.AnyProto” (or other classes).
I am using Google Firebase-Firestore DB, which implements grpc and uses nested dependency: com.google.protobuf:protobuf-lite:3.0.1.
Also, the google/Capillary library uses nested dependency: com.google.protobuf:protobuf-java:3.4.0.
If I exclude com.google.protobuf from the Capillary lib dependency only, the app will run, then crash when RSAKeyManager is instantiated, with error: “java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/protobuf/GeneratedMessageV3;” (I will not be implementing any direct client -> capillary service grpc, as both will have access to Firestore DB, and the capillary service will not be exposed to ingress)
To Reproduce I assume that adding google/Firestore dependencies to the demo/Android app will also cause this build error. It will sync/build in Android Studio, but build error occurs only when the app is run.
Expected behavior Through some form of gradle dependency exclusions, will I be able to get these packages to run in the same Android app?
Screenshots
I have tried using several combinations of package exclusions, including fully excluding com.google.protobuf from both Firestore and Capillary and implementing either separately:
implementation('com.google.protobuf:protobuf-java:3.4.0')
//{OR}
//implementation('com.google.protobuf:protobuf-lite:3.0.1')
implementation('com.google.firebase:firebase-firestore:18.2.0', {
exclude group: 'com.google.protobuf', module: 'protobuf-lite'
})
implementation('com.google.capillary:lib-android:1.0.0', {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
})
Issue Analytics
- State:
- Created 4 years ago
- Comments:14
With this library, please use “com.google.firebase:firebase-firestore:15.0.0”
If you want to use firestore with higher version, you can use command: “gradlew app: androidDependencies” to identify child components in firestore, and only implement necessary components.
You’ll want a
builtins { remove java }
. We do some of this is grpc, but don’t look at it too much because we do a lot of complex things 😃. But thegenerateProtoTasks
seen there is about what yours should look like.