Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build errors. Duplicate class android.support.v4

I have created a simple image to text app using Visual Studio following uTube guide https://www.youtube.com/watch?v=CLjzLiU_GpE

I am new to app dev and wanted to learn this but cant get to compile.

I have tried to follow similar errors in here Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes?

When I try to follow this and add to the AndroidStudioProjects\ImageToTextApp\gradle.properties I get more errors

My errors are as show but i have included (only) first and last 2, there are 390 in total.

I think i can see it tells me (as per other issues in here) that the class is in 2 libraries. (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)

Were do i see my project importing these libraries and how do I fix these errors.

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 android.support.v4.widget.ViewDragHelper$2 found in modules classes.jar (com.android.support:customview:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0) Duplicate class android.support.v4.widget.ViewDragHelper$Callback found in modules classes.jar (com.android.support:customview:28.0.0) and classes.jar (com.android.support:support-v4:24.0.0)

Go to the documentation to learn how to Fix dependency resolution errors.

Hi @BachVu I added your suggested line and the build.gradle file now looks like

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1' testImplementation 'junit:junit:4.13-beta-3' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.google.android.gms:play-services-vision:10.2.4' exclude module: 'support-v4' }

But this just creates more errors

ERROR: Gradle DSL method not found: 'exclude()'

Do i need to add another import or have i added in the wrong place?

like image 865
Paul Avatar asked Feb 16 '26 19:02

Paul


1 Answers

Try adding this line to the library that causes this issue exclude module: 'support-v4' like this:

implementation("androidx.recyclerview:recyclerview:x.x") {
        exclude group: 'com.android.support'
        exclude module: 'appcompat-v7'
        exclude module: 'support-v4'
    }
like image 80
Bach Vu Avatar answered Feb 19 '26 09:02

Bach Vu