Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encountering 'Gradle Duplicate class found' error after adding dependency

I'm looking to implement in-app updates and am following the guidance provided by Google

https://developer.android.com/guide/playcore/in-app-updates/kotlin-java#kts

As such i'm trying to add the following dependencies

implementation("com.google.android.play:app-update:2.0.0")
implementation("com.google.android.play:app-update-ktx:2.0.0")

However when trying to build the project I am confronted with a Duplicate class found error. One example provided below, although there are many of these

com.google.android.play.core.appupdate.AppUpdateInfo found in modules jetified-app-update-2.0.0-runtime (com.google.android.play:app-update:2.0.0) and jetified-core-1.10.2-runtime (com.google.android.play:core:1.10.2)

I tried to work. around this by adding some exclude clauses in configurations

configurations {
    all {
        exclude group: "com.google.android.play", module: "app-update"
        exclude group: "com.google.android.play", module: "core"
    }
}

The example above is the one that finally allowed the program to build, however when I go to utilise the library it is clear many of its elements have not been imported correctly. When I try to instantiate the AppUpdateManager, it is missing and AppUpdateResult seems to be the only one available to use.

enter image description here

Would really appreciate some guidance on what I may be doing wring here and any fixes or workarounds

like image 439
Murphler Avatar asked Apr 26 '26 03:04

Murphler


2 Answers

use this

implementation 'com.google.android.play:core:1.9.0'

and remove both

implementation("com.google.android.play:app-update:2.0.0")
implementation("com.google.android.play:app-update-ktx:2.0.0")
like image 144
Kamna Rai Avatar answered Apr 27 '26 17:04

Kamna Rai


I had a similar problem. In short, I was using com.google.android.play:core-ktx and wanted to migrate to "multiple per-feature libraries" (https://developer.android.com/guide/playcore#playcore-migration). But I kept getting "duplicate com.google.android.play:core" error message, even though I already removed it.

It turned out that one of the libraries I was using (androidx.navigation:navigation-dynamic-features-fragment:2.5.0-alpha03, to be specific) was including com.google.android.play:core:1.10.2 behind the scene. When I updated to androidx.navigation:navigation-dynamic-features-fragment:2.6.0-alpha08, the problem went away, and I was able to migrate to Google Play Core's per-feature libraries.

like image 34
solamour Avatar answered Apr 27 '26 15:04

solamour