Skip to content

Duplicate classes error when adding dialogflow dependency 0.98.0-alpha along with firebase #5608

Closed

Description

@h-amg

i'm getting a duplicate classes error when building with android studio gradle after i added dialogflow to my android app which uses firebase.

DEPENDENCIES:
these are my dependencies:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'com.github.VaibhavLakhera:Circular-Progress-View:0.1.2'
implementation 'com.github.CardinalNow:Android-CircleProgressIndicator:v0.2'
implementation 'ai.api:sdk:2.0.7@aar'
implementation 'ai.api:libai:1.6.12'
implementation 'com.google.cloud:google-cloud-dialogflow:0.98.0-alpha'
implementation 'io.grpc:grpc-okhttp:1.21.0'
implementation 'com.google.apis:google-api-services-oauth2:v2-rev99-1.21.0'
implementation 'com.google.apis:google-api-services-dialogflow:v2beta1-rev9-1.23.0'
implementation 'com.andkulikov:transitionseverywhere:2.0.0-beta01'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-firestore:20.1.0'

STACKTRACE:
This is part of the stacktrace as it continues to show duplicate classes arror (com.google.api.***) for another atleast 60 more classes:

Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) 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:17.0.0) 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:17.0.0) 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:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)

UNSUCCESSFUL ATTEMPTS:
I have tried exludsing the duplicated classes unsuccessdully using the below methods:

implementation('com.google.cloud:google-cloud-dialogflow:0.93.0-alpha'){ 
exclude group: 'com.google.api.grpc' 
exclude group: 'com.google.protobuf' 
}
implementation('com.google.cloud:google-cloud-dialogflow:0.99.0-alpha'){ 
exclude group: 'com.google.api.' 
}
implementation('com.google.cloud:google-cloud-dialogflow:0.99.0-alpha'){ 
exclude group: 'com.google' , module: 'api'
}
android {
	configurations {

	        all*.exclude group:'com.google.api.Advice', module: 'classes.jar'
	        all*.exclude group: 'com.google.api.Advice', module: 'proto-google-common-protos-1.16.0.jar'

    	}
}

Activity

  1. added
    triage me
    on Jul 1, 2019
  2. h-amg commented on Jul 1, 2019

    @h-amg
    Author

    I have narrowed down cause of the duplication to firestore dependency (com.google.firebase:firebase-firestore:20.1.0) and dialogflow dependency (implementation 'com.google.cloud:google-cloud-dialogflow:0.98.0-alpha)

  3. added
    api: dialogflow
    type: question
    and removed
    triage me
    on Jul 1, 2019
  4. h-amg commented on Jul 3, 2019

    @h-amg
    Author

    Hi @sduskis, I till haven't figured out a way to sort this issue, do you have any tip on anything i should try?

  5. h-amg commented on Jul 6, 2019

    @h-amg
    Author

    Hi @android10, I'd really appreciate your input on this. any thoughts on how to solve this problem?

  6. DavidBuzatu-Marian commented on Jul 7, 2019

    @DavidBuzatu-Marian

    @h-amg I have the exact same problem as you and I tried all the steps you said. Still, it doesn't work. Did you find a workaround?

  7. h-amg commented on Jul 7, 2019

    @h-amg
    Author

    @DavidBuzatu-Marian Nope, not yet. I'll post an update if i figured it out

  8. DavidBuzatu-Marian commented on Jul 7, 2019

    @DavidBuzatu-Marian

    @DavidBuzatu-Marian Nope, not yet. I'll post an update if i figured it out

    I've made a stackoverflow post and got a response, but I have an error. Maybe you can figure it out:

    https://stackoverflow.com/questions/56922949/resolve-duplicate-classes-with-firebase-and-dialog-flow

  9. h-amg commented on Jul 7, 2019

    @h-amg
    Author

    @DavidBuzatu-Marian Nope, not yet. I'll post an update if i figured it out

    I've made a stackoverflow post and got a response, but I have an error. Maybe you can figure it out:

    https://stackoverflow.com/questions/56922949/resolve-duplicate-classes-with-firebase-and-dialog-flow

    @DavidBuzatu-Marian The snippet lance provided is unnecessary since android studio lists all the duplicate classes and jars where they are located in the build window (part of which is included in my post above under "stacktrace"), in other words there is a similar script built into android studio that does this. The challenge is how to exclude the duplicate classes?

  10. DavidBuzatu-Marian commented on Jul 8, 2019

    @DavidBuzatu-Marian

    @h-amg I managed to exclude the classes, but I have something new in my code, maybe you did it differently and won't have it.

    I added this to gradle (module) just above dependencies:

    configurations {
    implementation.exclude module:'proto-google-common-protos'
    implementation.exclude module:'protobuf-java'
    }

  11. h-amg commented on Jul 9, 2019

    @h-amg
    Author

    Hey @DavidBuzatu-Marian, thank you so much. This method worked though i had to modify it a little bit. (for those landing on this page in search for a solution to the same problem. post the below code into your build.gradle (module app) file)

    android {
        ... 
    
    
       configurations {
                 implementation.exclude module:'proto-google-common-protos'
                 implementation.exclude module:'protolite-well-known-types'
                 implementation.exclude module:'guava'
                 implementation.exclude module:'protobuf-lite'
        }
    
    }
    

    Let me know if this works for you.

  12. 20 remaining items

  13. shiran82 commented on Aug 7, 2019

    @shiran82

    I have the same issue, @h-amg I added what you suggested and there are no duplicates, however i still get: Verifier rejected class com.google.firestore.v1.WriteResponse
    I tried adding protobuf 'com.google.protobuf:protobuf-java:3.6.1' and it works but then when i try to build in release mode it doesn't compile
    Any suggestions?

  14. h-amg commented on Aug 8, 2019

    @h-amg
    Author

    @shiran82 yeah thats what i got too, unfortunate i could't figure out how to get it to work. The fact is dialogflow is not supported for android so you are pretty much on your own. i ended switching to mongodb stitch.

  15. carlosrsabreu commented on Dec 27, 2019

    @carlosrsabreu

    @h-amg did you tried to use the Realtime Database instead of the Cloud Firestore? It's working fine on my project and doesn't give the errors that you have: duplicate classes.

  16. kaniundungu commented on Feb 15, 2020

    @kaniundungu

    Here's a great workaround for those who can't wait for an official fix:

    protocolbuffers/protobuf#7094 (comment)

    The idea behind it is to 'fatjar' the proto artifacts in a sequence that overwrites classes that do not work well with firesbase firestore or inappmessaging.

  17. 99ansh commented on Apr 12, 2020

    @99ansh

    @Laguses I followed the steps you have mentioned but because I have copied the com folder from protolite-well-known-types, and not excluded it, I still get Duplicate class error between new protolite. jar and protolite-well-known-types.jar Can you please help me out? I am stuck on this for more than a week now.

    @athakor I have added the exclusion but still, gives me duplicate class error

  18. lordciriuz commented on May 10, 2020

    @lordciriuz

    The workarround just work if you are using protobuf-javalite. The title is confusing, be careful.

    I am trying to use protobuf-java 3.11.4 (full version, no lite) with Firestore 21.4.3 and it seems to be impossible, due to internal incompatibilities with different protobuf versions.

    I have to use protobuf-java because my app needs Any type message.

    I would like to know if there is a way to accomplish that. If it is not, I will move away from Firestore.

  19. rakeshprojects commented on Jul 31, 2020

    @rakeshprojects

    lintOptions {
    checkReleaseBuilds false
    }

    Thank you man!!!!! its working............i got stuck for last few days and you really help me. Thank you again

  20. giovappp commented on Dec 24, 2020

    @giovappp

    I have the same problem, I followed some solutions proposed here, only I could not solve the problem of duplicate classes. Anyone have a solution?

  21. Yoginee47 commented on Feb 2, 2021

    @Yoginee47

    @h-amg I have followed some of the solutions given here.. I dont have any compile issues like duplicate classes but app crashes when performing any firestore operation..Is there a way to use both firestore and dialogflow at the same time or i have to change my db? If anyone could help really appreciate it..

  22. h-amg commented on Feb 2, 2021

    @h-amg
    Author

    @Yoginee47 I had to change my db to mongodb at the end to resolve this issue. I hope this helps

  23. Yoginee47 commented on Mar 2, 2021

    @Yoginee47

    @h-amg Firestore provides the REST API to access the database... Should we consider using that in place of firestore sdk?
    Would appreciate your views on this..

  24. h-amg commented on Mar 3, 2021

    @h-amg
    Author

    @Yoginee47 hi, I think that will help. Since you no longer use the FIRE STORE SDK and therefore avoid the dependencies conflict.

  25. guneet-appinventiv commented on Dec 1, 2021

    @guneet-appinventiv

    This worked for me:

    android{
      ...
      packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/INDEX.LIST'
        }
    }
    dependencies{
      ...
      implementation ('com.google.cloud:google-cloud-speech:0.41.0-alpha'){
            exclude module: 'protobuf-javalite'
            exclude module: 'protobuf-java'
            exclude module: 'proto-google-common-protos'
        }
    }
    
    

    Ref:

    https://github.com/GoogleCloudPlatform/android-docs-samples/blob/master/speech/SpeechRecognitionClient/app/build.gradle

    https://stackoverflow.com/a/64226363/8459761

  26. PriyavratTalyan commented on Feb 16, 2022

    @PriyavratTalyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: dialogflowdependenciestype: question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions