Duplicated classes found in modules classes.jar

后端 未结 2 2054
礼貌的吻别
礼貌的吻别 2021-01-04 23:54

Working with \"Cxense SDK for Android\", I\'m getting the message of duplicated class:

Duplicate class android.support.v4.app.INotification         


        
相关标签:
2条回答
  • 2021-01-05 00:24

    There are two ways to fix your issue.

    1. Excluding duplicated dependencies while implementation individually,

    2. Excluding duplicated dependencies from every implementations in generic way.

    Let's first understand the problem :

    Here, in your case artifact com.android.support is duplicated, because your app module uses version : 27.1.1 while your artifact com.cxpublic:cxense-android:1.0.1 is having internal dependency of com.android.support uses version : 22.2.0.

    So, you should remove one of them manually (removing older or lower version is recommended). Let's try to remove it !


    By first approach:

    implementation ('com.cxpublic:cxense-android:1.0.1') {
        exclude group: "com.android.support", module: "support-v4"
    }
    

    Putting exclude for group com.android.support in our artifact com.cxpublic:cxense-android:1.0.1 will not get imported for support-v4 libraries when we use our implementation on this artifact.

    So, issue would be resolved by manually putting this block to every artifact having this conflict.

    By Second way:

    We can remove included dependencies and replace them with one package with latest number. In our case, it is support-v4 with different version. So, go to the android block of app level build.gradle and put below block there to remove duplicated support-v4 from all artifacts, so that we can have distinct dependency.

    android {
        // Some other stuffs
        configurations {
            all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
        }
        // Rest of other stuffs
    }
    
    0 讨论(0)
  • 2021-01-05 00:35

    If there are duplicates, use exclude:

    implementation ('com.cxpublic:cxense-android:1.0.1') {
        exclude group: "com.android.support", module: "support-v4"
    }
    

    Or remove implementation 'com.android.support:appcompat-v7:27.1.1' in favour of support-v4.

    See: https://discuss.gradle.org/t/how-do-i-exclude-specific-transitive-dependencies-of-something-i-depend-on/17991

    0 讨论(0)
提交回复
热议问题