I completely new to Android Development and can't seem to resolve this error: "Error: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback"
This is my dependencies:
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.0-alpha1' implementation 'androidx.constraintlayout:constraintlayout:1.1.2' implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1' implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1' implementation "android.arch.navigation:navigation-fragment:1.0.0-alpha01" implementation "android.arch.navigation:navigation-ui:1.0.0-alpha01" androidTestImplementation 'androidx.test:runner:1.1.0-alpha3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3' testImplementation 'junit:junit:4.12' }
I've googled some and ended up on the developer page about "Resolve duplicate class errors", but I'm still not able to fix this. Help would be very much appriciated!
4 Answers
Answers 1
Option 1
Following worked for me Add the following in your gradle.properties file
android.useAndroidX = true android.enableJetifier = false
Option 2 (if above does't work)
- Android studio > Navigate -> Class
- Check include non-project classes
- Copy full class path android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
- See where it is used. You may need to remove, one of them.
Option 3 you might be including package which is including modules as well so exclude the support-v4 module with following method
implementation ('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') { exclude group: 'com.android.support', module:'support-v4' }
Answers 2
At least for me the issue was with the implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
dependency. I went into the menu in Android Studio to create a Blank Fragment in Kotlin just to see what that would look like and the dependency above was added.
Once i removed that dependency the error went away.
Answers 3
It is seen that Android studio wrongly show the error.
Try clearing cache. File -> Invalidate Caches / Restart -> Invalidate and Restart
Answers 4
Some of your existing dependencies are using older versions of support library, try this
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1' { exclude group: 'com.android.support' exclude module: 'support-v4' }
0 comments:
Post a Comment