Why I'm Getting Duplicate Class When Running My Android Project

筅森魡賤 提交于 2019-11-29 15:16:07

This error means there are libraries which have same methods and complier won't be able to distinguish which of them should be used in your project and error thrown. You must exclude conflicted library in your Gradle file. As Log shows, classes.jar module has duplicated classes.

    android{
    ...
        configurations {

                all*.exclude group:'android.support.v4.app' module: ‘classes.jar’
                all*.exclude group:'android.support.v4.accessibilityservice' module: ‘classes.jar’
        }
    }

This will resolved exception.

Go to gradle.properties and write these two lines of code:

android.useAndroidX=true android.enableJetifier=true

Please update com.google.android.gms:play-services to latest version. it wil work.

See if adding this dependency works:

implementation 'com.android.support:support-v4:28.0.0'

I got this problem resolved by creating a new project with the same project name and same id and then copying files from the previous project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!