Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback

前端 未结 5 1450
死守一世寂寞
死守一世寂寞 2020-12-09 14:43

I completely new to Android Development and can\'t seem to resolve this error: \"Error: Program type already present: android.support.v4.media.MediaBrowserCompat$Custom

相关标签:
5条回答
  • 2020-12-09 15:12

    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.

    0 讨论(0)
  • 2020-12-09 15:16

    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 讨论(0)
  • 2020-12-09 15:20

    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)

    1. Android studio -> Navigate -> Class
    2. Check include non-project classes
    3. Copy full class path android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
    4. 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'
    }
    

    You can analyze the conflicting modules using ./gradlew :YOURPROJECT:dependencies from a command line in your project repository. Check especially your third party libraries for occurences of "com.android.support-":

    Then exclude the conflicting modules from these dependencies like:

       implementation ("com.jakewharton:butterknife:8.8.1") {
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotation'
        exclude group: 'com.android.support', module: 'support-compat'
    }
    
    0 讨论(0)
  • 2020-12-09 15:25

    Im using flutter, and Im adding some native libraries in android, I tried the solutions posted here, but the trick for me was android.enableJetifier = true instead false

    So, adding the following code to the gradle.properties, my apps are running:

    android.useAndroidX = true
    android.enableJetifier = true
    
    0 讨论(0)
  • 2020-12-09 15:37

    if you still getting error after

    # gradle.properties
    android.useAndroidX = true
    android.enableJetifier = false
    

    then you probably forgot about main activity that calling android.support.v7.app.AppCompatActivity change it to androidx.appcompat.app.AppCompatActivity

    0 讨论(0)
提交回复
热议问题