ejshin1
ejshin1

Reputation: 1167

Duplicate class android.support.v4.app.NotificationCompat$Action$Extender found in modules classes.jar (com.android.support:support

I'm getting multiple lines of errors saying that it has duplicate class

Duplicate class

android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0) Duplicate class android.support.v4.app.ActionBarDrawerToggle found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0) Duplicate class Go to the documentation to learn how to Fix dependency resolution errors.

My gradle.app has dependencies as below:

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.android.gms:play-services:10.2.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

Upvotes: 3

Views: 2187

Answers (3)

Aditya Jain
Aditya Jain

Reputation: 11

// paste this properties in gradle.properties

android.useAndroidX=true

android.enableJetifier=true

  1. First Property will use appropriate androidx libraries instead of using old support libraries.

  2. Second will migrate all third party libraries to androidx libraries.

Upvotes: 0

Al Sadiq Insitute
Al Sadiq Insitute

Reputation: 49

thanks the above answer by Jorgesys is correct but i migrate to androidx which solved my problem

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

Upvotes: 0

Jorgesys
Jorgesys

Reputation: 126455

You need to upgrade the version, you can do this by using the sequence Alt+Enter over the line:

enter image description here

Nowadays you don´t need to use all Google Play Services, just modules, examples:

implementation 'com.google.android.gms:play-services-ads:VERSION'
implementation 'com.google.android.gms:play-services-auth:VERSION'
implementation 'com.google.android.gms:play-services-gcm:VERSION'

but if you really need to use 'com.google.android.gms:play-services:VERSION', to avoid duplicated classes uses this configuration inside your app/build.gradle file:

implementation ('com.google.android.gms:play-services:10.2.4') {
    exclude group: "com.android.support", module: "support-v4"
}

Upvotes: 1

Related Questions