2

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?

Paul
  • 59
  • 1
  • 6

4 Answers4

2

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'
    }
Bach Vu
  • 2,298
  • 1
  • 15
  • 19
  • Hi @BachVu. Sorry for a load of goes at adding a comment. - See the question now, I have added some code at the end as per your suggestion and the error I now get is the function exclude() cannot be found. – Paul May 28 '19 at 11:03
  • @Paul Can you strictly follow the syntax with the parathensis? This one {} – Bach Vu May 29 '19 at 03:50
1

Here is my build.Gradle file now and all works fine;

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:17.0.2' }

The main difference is

com.google.android.gms:play-services-vision:10.2.4

For some reason this was okay then out of nowhere it advised it was out of date. Once I updated from 10.2.4 > 17.0.2 all the errors went away.

Thanks for your time.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Paul
  • 59
  • 1
  • 6
1

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

android.useAndroidX=true # may be set already
android.enableJetifier=true
Julius Babies
  • 955
  • 3
  • 6
  • 22
YuvrajsinhJadeja
  • 1,383
  • 7
  • 23
1

Try to migrate AndroidX

==> Step 1
Just go to
Refactor > Migrate to AndroidX > Migrate > Do Refactor

==> Step 2
Update your classPath and all dependencies with the latest version(Alt+Enter)
jay patoliya
  • 611
  • 7
  • 8