Reputation: 644
I am working on a mobile app where I need dialog-flow in order to get some information from a user message. The problem is, when I implement dialog-flow into the app gradle, I get an error on build, saying that I have multiple duplicate classes ( conflicting with firebase classes).
I've tried methods suggested here: https://stackoverflow.com/a/51695425/11023871
and even searched on the github repository of dialog-flow: https://github.com/googleapis/google-cloud-java/issues/5608#issue-462434090
I tried to exclude 'google-protobuf', but that didn't help (I got compilation error on dialog-flow components).
I attached my dependencies below.
dependencies {
implementation 'com.hbb20:ccp:2.2.4'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-firestore:19.0.2'
implementation 'com.google.cloud:google-cloud-dialogflow:0.99.0-alpha'
}
EDIT These are some of the duplicates specified by gradle: Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AdviceOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AnnotationsProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Upvotes: 4
Views: 5503
Reputation: 121
I was stuck with the same issue and after months of debugging and thanks to an update from Google and Firebase, I came by a solution that's working. I needed to change library versions of Firebase and dialog flow. Change min SDK version to 19 if lesser than 19 in your project.
Upvotes: 3
Reputation: 28016
I have the duplicate classes and it's jars, but I never excluded something from gradle. Could you please help me out? For example, I have this: "Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)"
I'm not sure why these jars are duplicating the same classes or which one you want to keep. But you can do something like
dependencies {
implementation 'com.hbb20:ccp:2.2.4'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
...
}
configurations.implementation.exclude(group: 'com.google.firebase', module: 'protolite-well-known-types')
Upvotes: 0
Reputation: 28016
Add the following snippet to your build.gradle
and then run gradle findDuplicates
. This will list any duplicate classes and which jars they are in. After that you can see which ones you want to exclude.
task findDuplicates {
doLast {
Map<String, List<File>> pathMap = [:]
configurations.runtime.each { file ->
FileTree tree = file.directory ? fileTree(file) : zipTree(file)
tree.visit { FileVisitDetails fvd ->
if (!fvd.directory) {
String path = fvd.path
List<File> fileList = pathMap[path]?:[]
fileList << fvd.file
pathMap[path] = fileList
}
}
}
pathMap.each { path, fileList ->
if (fileList.size() > 1) {
println "Found duplicate $path in $fileList"
}
}
}
}
Upvotes: 1