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

前端 未结 26 2987
伪装坚强ぢ
伪装坚强ぢ 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:46

    I removed compile 'com.android.support:support-v4:18.0.+' in dependencies, and it works

    0 讨论(0)
  • 2020-11-22 02:47
    exclude module: 'support-v4'
    

    Would not work for me with a project dependency, the only way I could get it to work was via the following syntax:

    configurations {
        dependencies {
            compile(project(':Android-SDK')) {
                compile.exclude module: 'support-v4'
            }
        }
    }
    

    Where :Android-SDK is your project name.

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

    I had this same error but it was because I had recently changed from using v4 to v13. So all I had to do was clean the project.

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

    Received the following error

    Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.

    com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/constraint/ConstraintSet$1

    Fix : go to Build -> Clean Project

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

    I was able to solve the problem in my react native project by simply adding

    configurations {
            all*.exclude group: 'com.android.support', module: 'support-compat'
            all*.exclude group: 'com.android.support', module: 'support-core-ui'
        }
    

    at the end of my android\app\build.gradle file

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

    Run gradle -q dependencies (or gradle -q :projectName:dependencies) to generate a dependency report. You should see where r7 is coming from, such as:

    compile - Classpath for compiling the main sources.
    +--- com.commonsware.cwac:camera-v9:0.5.4
    |    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
    |    |    \--- com.google.android:support-v4:r7
    |    +--- com.commonsware.cwac:camera:0.5.4
    |    \--- com.android.support:support-v4:18.0.+ -> 18.0.0
    \--- com.android.support:support-v4:18.0.+ -> 18.0.0
    

    Then, use the exclude directive to block that dependency. In my case, it is coming from my CWAC-Camera library, and so I use:

    dependencies {
        compile('com.commonsware.cwac:camera-v9:0.5.4') {
          exclude module: 'support-v4'
        }
    
        compile 'com.android.support:support-v4:18.0.+'
    }
    

    (where the second compile statement indicates what version you actually want)

    That should clear matters up, as you will see if you run the dependency report again:

    compile - Classpath for compiling the main sources.
    +--- com.commonsware.cwac:camera-v9:0.5.4
    |    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
    |    \--- com.commonsware.cwac:camera:0.5.4
    \--- com.android.support:support-v4:18.0.+ -> 18.0.0
    
    0 讨论(0)
提交回复
热议问题