Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

前端 未结 26 2988
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 02:29

If I run gradle assembleDebug from the command line, I am suddenly getting this error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexEx         


        
相关标签:
26条回答
  • 2020-11-22 02:53

    In Android Studio, go to your build.gradle (check both project and modules build.gradle files) and search for duplicate dependencies.

    Delete those your project does not need.

    0 讨论(0)
  • 2020-11-22 02:53

    I had the same problem when adding react-native-palette to my project, here is my dependencies tree:

    ./gradlew app:dependencies
    +--- project :react-native-palette
    |    +--- com.facebook.react:react-native:0.20.+ -> 0.44.2
    |    |    +--- javax.inject:javax.inject:1
    |    |    +--- com.android.support:appcompat-v7:23.0.1
    |    |    |    \--- com.android.support:support-v4:23.0.1
    |    |    |         \--- com.android.support:support-annotations:23.0.1 -> 24.2.1
    ...
    |    \--- com.android.support:palette-v7:24.+ -> 24.2.1
    |         +--- com.android.support:support-compat:24.2.1
    |         |    \--- com.android.support:support-annotations:24.2.1
    |         \--- com.android.support:support-core-utils:24.2.1
    |              \--- com.android.support:support-compat:24.2.1 (*)
    +--- com.android.support:appcompat-v7:23.0.1 (*)
    \--- com.facebook.react:react-native:+ -> 0.44.2 (*)
    

    I tried many solutons and could not fix it, until changing the com.android.support:appcompat version in android/app/build.gradle, I wish this can help:

    dependencies {
        compile project(':react-native-palette')
        compile project(':react-native-image-picker')
        compile project(':react-native-camera')
        compile fileTree(dir: "libs", include: ["*.jar"])
        // compile "com.android.support:appcompat-v7:23.0.1"
        compile "com.android.support:appcompat-v7:24.2.1"
        compile "com.facebook.react:react-native:+"
    }
    

    it seems that multiple entries is not a big problem, version mismatch is

    0 讨论(0)
  • 2020-11-22 02:56

    Since A picture is worth a thousand words

    To make it easier and faster to get this task done with beginners like me. this is the screenshots that shows the answer posted by @edsappfactory.com that worked for me:

    First open the Gradle view on the right side of Androidstudio, in your app's item go to Tasks then Android then right-click androidDependencies then choose Run:

    Second you will see something like this :

    The main reason i posted this that it was not easy to know where to execute a gradle task or the commands posted above. So this is where to excute them as well.

    SO, to execute gradle command:

    First:

    Second:

    Easy as it is.

    Thats it.

    Thank you.

    0 讨论(0)
  • 2020-11-22 02:56

    I had the same error on a legacy project. My fault was that the support-library was included twice: Once inside google-play-services lib, and another as standalone.

    This is how I fixed it:

    BAD build.gradle:

    dependencies {
       compile files('libs/android-support-v4.jar') 
       compile files('libs/core-2.2.jar')
       compile files('libs/universal-image-loader-1.8.5-with-sources.jar')
       compile 'com.google.android.gms:play-services:3.2.65'
    }
    

    GOOD build.gradle:

    dependencies {
       // compile files('libs/android-support-v4.jar')  // not needed 
       compile files('libs/core-2.2.jar')
       compile files('libs/universal-image-loader-1.8.5-with-sources.jar')
       compile 'com.google.android.gms:play-services:3.2.65'
    }
    

    Hope it helps someone :-)

    0 讨论(0)
  • 2020-11-22 02:56

    If you have imported your project from Eclipse.

    1. The select project 
    2. Go to File -> **Project Structure**
    3. Select app in **module** section on left hand panel
    4. Select **Dependency** tab
    5. Your able to see jars you have added in eclipse project for v4 and v13.
    6. Remove that jar by clicking on minus sign at bottom after selection
    7. Click on Plus sign select **Library Dependency** 
    8. Choose V4 and V13 if added
    9. Press Ok and Clean and Rebuild your project
    

    The scenario I have faced after importing Eclipse project to Android studio.

    Hope this helps..

    0 讨论(0)
  • 2020-11-22 02:56

    I had the same problem, and my solution is changing the support version '27.+'(27.1.0) to '27.0.1'

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