Error: Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat

前端 未结 10 2043
暗喜
暗喜 2020-12-10 03:56

After upgrading to Android Studio 3.1, I started to get following error during build. Project uses multidex and DX is enabled by default as you would notice in the error. I

相关标签:
10条回答
  • 2020-12-10 04:14

    I managed to determine the root cause by using the following steps. It may be different use case for each issue, therefore this is the way to determine the root cause.

    • Go to android studio
    • Navigate -> Class
    • Check include non-project classes
    • Copy paste full class path with package name. android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
    • You should be able to see where it is used. Most probably you may need to remove it from one of them.

    In my case the issue was ViewPagerIndicator library was downloading support library as jar. Removing it solved the issue.

    0 讨论(0)
  • 2020-12-10 04:16

    I also faced the same problem just a while ago. In my case the third party library used the older AccessibilityServiceInfoCompat version v4 22 and i already updated to newer one v4 28 so both support library classes clashed

    0 讨论(0)
  • 2020-12-10 04:16

    In y case I've resolved issue by

    implementation 'com.android.support:appcompat-v7:26.0.0'
    

    to

     implementation 'com.android.support:appcompat-v7:27.1.1'
    
    0 讨论(0)
  • 2020-12-10 04:16
    I have my solution by change this :
    android / build.gradle
    buildscript {
        ext {
            supportLibVersion = "27.0.3"
        }
    }
    to
    buildscript {
        ext {
            supportLibVersion = "26.0.0"
        }
    }
    directory android / app / build.gradle
    defaultConfig {
        multiDexEnabled true
    }
    
    0 讨论(0)
  • 2020-12-10 04:27

    For the easy option just add

    configurations.all {exclude group: 'com.android.support', module: 'support-v4'}
    

    before dependencies in build.gradle app module, it should ignore v4 support libraries, and the duplicate error will go away.

    0 讨论(0)
  • 2020-12-10 04:27

    As for me this helps to resolve such issues

    all support libraries (also included thirdy-part) reduces to specified version

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '28.0.0-beta01'
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题