Ad

Resolve Duplicate Classes With Firebase And Dialog-flow

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)

Ad

Answer

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') 
Ad
source: stackoverflow.com
Ad