Android Gradle Dependency Duplicate Class Error - android

After installing Square's Reader SDK into my app, I'm running into duplicate class errors between some Gradle dependencies as shown below.
My app module dependencies:
dependencies {
def readerSdkVersion = "1.3.5"
implementation "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APPLICATION_ID:$readerSdkVersion"
runtimeOnly ("com.squareup.sdk.reader:reader-sdk-internals:$readerSdkVersion") {
exclude group: 'com.squareup.phrase', module: 'phrase'
}
implementation 'com.squareup.phrase:phrase:1.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.multidex:multidex:2.0.1'
}
... and the build failure I get even though I tried excluding the conflicting group/module from Square's Phrase dependency:
Duplicate class com.squareup.phrase.BuildConfig found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.ListPhrase found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.ListPhrase$1 found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.ListPhrase$Formatter found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$KeyToken found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$LeftCurlyBracketToken found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$TextToken found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$Token found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Am I missing something here? And yes, I have all of the other Gradle configurations (i.e. multidex and compile options set) as mentioned in the SDK's docs mentioned earlier.

Related

Gradle - Android - In App Review causes compile error - Amplify old dependency

I am trying to integrate In App Review and I get this compile error:
Duplicate class com.google.android.play.core.common.IntentSenderForResultStarter found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.common.LocalTestingException found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.common.PlayCoreDialogWrapperActivity found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.listener.StateUpdatedListener found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-core-common-2.0.0-runtime (com.google.android.play:core-common:2.0.0)
Duplicate class com.google.android.play.core.review.ReviewInfo found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-review-2.0.0-runtime (com.google.android.play:review:2.0.0)
Duplicate class com.google.android.play.core.review.ReviewManager found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-review-2.0.0-runtime (com.google.android.play:review:2.0.0)
Duplicate class com.google.android.play.core.review.ReviewManagerFactory found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-review-2.0.0-runtime (com.google.android.play:review:2.0.0)
Duplicate class com.google.android.play.core.review.testing.FakeReviewManager found in modules jetified-core-1.9.1-runtime (com.google.android.play:core:1.9.1) and jetified-review-2.0.0-runtime (com.google.android.play:review:2.0.0)
Go to the documentation to learn how to Fix dependency resolution errors.
Edit: I ran the command: ./gradlew app:dependencies >> deps.txt
and found out that the conflict is caused by Amplify core. It has a dependency on androidx.navigation:navigation-dynamic-features-fragment:2.3.4 for some reason and that's has com.google.android.play:core:1.9.1 inside.
How can I prevent Amplify causing this? How to solve this confilct?
Here is the dependency tree
I was able to solve this by changing the gradle file:
// gradle imports from Amplify docs below.
implementation('com.amplifyframework:aws-storage-s3:1.35.4') {
exclude group: 'com.google.android.play', module: 'core'
}
implementation('com.amplifyframework:aws-auth-cognito:1.35.4') {
exclude group: 'com.google.android.play', module: 'core'
}
// Amplify core dependency
implementation('com.amplifyframework:core:1.35.4') {
exclude group: 'com.google.android.play', module: 'core'
}

Different libraries depend on the same library and will prompt "Duplicate class" during compilation. How to exclude this duplicate class?

error like this:
Duplicate class com.google.android.exoplayer2.ui.AspectRatioFrameLayout found in modules jetified-VideoPlayModule-Lite-2.3.61-runtime.jar (com.ycjiang:VideoPlayModule-Lite:2.3.61) and jetified-exoplayer-ui-2.12.1-runtime.jar (com.google.android.exoplayer:exoplayer-ui:2.12.1)
Duplicate class com.google.android.exoplayer2.ui.AspectRatioFrameLayout$1 found in modules jetified-VideoPlayModule-Lite-2.3.61-runtime.jar (com.ycjiang:VideoPlayModule-Lite:2.3.61) and jetified-exoplayer-ui-2.12.1-runtime.jar (com.google.android.exoplayer:exoplayer-ui:2.12.1)
gradle:
implementation 'com.google.android.exoplayer:exoplayer:2.12.1'
implementation 'com.ycjiang:VideoPlayModule:2.3.61'

Android parse-SDK-android and facebook SDK incompatibility

Latest versions of android parse SDK (1.24.x) include bolts-tasks instead of referencing it. In an app which also use Facebook SDK this leads to duplicate classes :
java.lang.RuntimeException: Duplicate class bolts.AggregateException found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.AndroidExecutors found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.AndroidExecutors$1 found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.AndroidExecutors$UIThreadExecutor found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.BoltsExecutors found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
Duplicate class bolts.BoltsExecutors$1 found in modules bolts-tasks-1.24.1.jar (com.github.parse-community.Parse-SDK-Android:bolts-tasks:1.24.1) and bolts-tasks-1.4.0.jar (com.parse.bolts:bolts-tasks:1.4.0)
...
Is there a solution ?
try this
implementation ("com.github.parse-community.Parse-SDK-Android:parse:1.24.1"){
exclude module:'bolts-tasks'
}
If it doesn't work then try this
implementation ("com.github.parse-community.Parse-SDK-Android:parse:1.24.1"){
exclude group:'com.github.parse-community' ,module:'bolts-tasks'
}
if you are using com.facebook.fresco:fresco then following solution is working
implementation ('com.facebook.fresco:fresco:2.1.0'){
exclude module:'bolts-tasks'
}
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.24.1"
try this works for me
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.24.1"
implementation ('com.github.parse-community:ParseFacebookUtils-Android:1.14.0'){
exclude module: 'bolts-android'
}

Duplicate class com.google.api.client.http.apache.ApacheHttpRequest found in modules

I am trying to migrate to drive v3 api for my android app and I have followed instructions provided inhttps://github.com/gsuitedevs/android-samples/tree/master/drive/deprecation to migrate. I am getting dependency resolution errors.
I have used duplicate classes shown in log in exclude option but it haven't worked
list of my drive api dependencies
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.http-client:google-http-client-gson:1.29.1'
implementation('com.google.api-client:google-api-client-android:1.28.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-drive:v3-rev99-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
Below are the error lines shown
Duplicate class com.google.api.client.http.apache.ApacheHttpRequest found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ApacheHttpResponse found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ApacheHttpTransport found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.ContentEntity found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Duplicate class com.google.api.client.http.apache.HttpExtensionMethod found in modules google-http-client-1.29.1.jar (com.google.http-client:google-http-client:1.29.1) and google-http-client-apache-2.0.0.jar (com.google.http-client:google-http-client-apache:2.0.0)
Looking at the error message:
found in modules google-http-client-1.29.1.jar
it seems to reference:
implementation 'com.google.http-client:google-http-client-gson:1.29.1'
Based upon the version number. Have you tried to exclude the library from that artefact too?

Android build error when implementing google places sdk

Hello everyone I am developing simple food delivery android application so its required to integrate google maps and auto suggestion I follow to find current location
[google sample code](https://github.com/googlemaps/android-samples/blob/master/tutorials/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.java)
and for Auto suggestions I followed
https://developers.google.com/places/android-sdk/autocomplete
when build it gradle shows duplicate class error
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult$StructuredFormatting found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult$Substring found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.FetchPlacePabloResponse found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.bc found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.bd found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.be found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
And this my gradle
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
i try to exclude duplicate classes by below way
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation ('com.google.android.libraries.places:places:1.1.0'){
exclude group:'com.google.android.libraries.places.api.internal.impl.net.pablo'
exclude group: 'com.google.android.libraries.places.internal'
}
But no thing can solve my problem.
Remove
implementation'com.google.android.libraries.places:places-compat:1.1.0'
and keep only implementation 'com.google.android.libraries.places:places:1.1.0'.
Using implementation 'com.google.android.libraries.places:places-compat:1.1.0'
is neccessary only if you are using deprecated library of
implementation 'com.google.android.gms:play-services-places:16.0.0'
Please take a look here and documentation.

Categories

Resources