Duplicate classes androidx.appcompat: Android studio

Viewed 78

I'm getting the following error message on running my program, with Android Studio, kotlin version 1.7.10, jetpack compose:

Duplicate class androidx.appcompat.content.res.AppCompatResources found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$1 found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimatableTransition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimatedStateListState found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimatedVectorDrawableTransition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimationDrawableTransition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$FrameInterpolator found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$Transition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer$1 found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer$BlockInvalidateCallback found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer$DrawableContainerState found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.DrawableWrapper found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.StateListDrawable found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.graphics.drawable.StateListDrawable$StateListState found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.widget.DrawableUtils found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.widget.ResourcesWrapper found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.widget.TintContextWrapper found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.widget.TintInfo found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.widget.TintResources found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1) Duplicate class androidx.appcompat.widget.VectorEnabledTintResources found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and appcompat-resources-1.4.1-runtime (androidx.appcompat:appcompat-resources:1.4.1)

The problem is probably because of transitive dependencies in google play-services, but I'm not sure how to fix it. It began after adding this:

implementation ('com.google.android.libraries.places:places:2.6.0')

I've tried this but it didn't work:

implementation ('com.google.android.libraries.places:places:2.6.0')
  {exclude(group: 'androidx.appcompat', module: 'appcompat:1.0.0) }

Full list of dependencies:

dependencies {
implementation ('androidx.core:core-ktx:1.8.0')
implementation("androidx.compose.ui:ui:1.2.1") 
implementation("androidx.compose.material:material:1.2.1") 
implementation "androidx.compose.ui:ui-tooling-preview:1.2.1" 
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' 
implementation 'androidx.activity:activity-compose:1.5.1'
implementation ('com.google.android.gms:play-services-location:20.0.0')
implementation ('com.google.android.libraries.places:places:2.6.0') 
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.2.1" 
debugImplementation "androidx.compose.ui:ui-tooling:1.2.1" 
debugImplementation "androidx.compose.ui:ui-test-manifest:1.2.1" 

implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'

implementation 'com.squareup.moshi:moshi-kotlin:1.13.0'

implementation("io.coil-kt:coil-compose:2.1.0")


implementation 'com.google.code.gson:gson:2.9.0' 

implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"

implementation "androidx.room:room-runtime:2.4.3" //2.4.3
implementation "androidx.room:room-ktx:2.4.3" //2.4.3
implementation "androidx.compose.runtime:runtime-livedata:1.2.1" // 1.2.1
annotationProcessor "androidx.room:room-compiler:2.4.3" // 2.4.2 -> 2.4.3
kapt "androidx.room:room-compiler:2.4.3" //  2.4.2 -> 2.4.3

implementation 'com.google.maps.android:maps-compose:2.5.3' //1.2.0 -> 2.5.3

implementation 'com.google.android.gms:play-services-maps:18.1.0' //18.0.2 -> 18.1.0
implementation("androidx.room:room-ktx:2.4.3")
implementation "androidx.navigation:navigation-compose:2.5.1"
androidTestImplementation "androidx.navigation:navigation-testing:2.5.1"
implementation 'com.sealwu.jsontokotlin:library:3.7.4'

I've been trying for hours now, can't find exactly how to fix it. Grateful for any help.

0 Answers
Related