1

I want to import Coil library in my project. I did it like below:

android{
   compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }

dependencies {
    implementation("io.coil-kt:coil:0.8.0")
}

The project will sync successfully, But When I want to run the application I 'll face with this error:

Duplicate class androidx.appcompat.content.res.AppCompatResources found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
    Duplicate class androidx.appcompat.content.res.AppCompatResources$ColorStateListCacheEntry found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$1 found in modules classes.jar (androidx.appcompat:appcompat-resources:1.1.0) and classes.jar (androidx.appcompat:appcompat:1.0.0)

My app is converted to the AndroidX before. Also, my targetSdkVersion = 29 and minSdkVersion = 17

Ehsan
  • 2,042
  • 4
  • 23
  • 44

2 Answers2

1

You need appcompat library

implementation "androidx.appcompat:appcompat:1.1.0"

0

You need appcompat library

implementation "androidx.appcompat:appcompat:1.1.0"

This is correct but you also need to

Go to gradle.properties and add

android.enableJetifier=true
android.useAndroidX=true

I had the same problem and I think it's related to the last version of Androidx.

Anyway you probably have one dependency using an old version of androidx.appcompat. Setting enableJetifier=true will force the use of the most recent one.

For info I'm using Coil on version

implementation "io.coil-kt:coil:0.10.0"
Community
  • 1
  • 1
chip
  • 191
  • 7