Multiple dex files define Landroid / support / v4 /

I cannot compile the project, it gets the following error compilation:

Error: execution completed for task ': myApp: dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to execute the command: C: \ Program Files (x86) \ Android \ android-studio \ sdk \ build-tools \ 21.0.2 \ dx.bat --dex - output C: \ Users \ Android Studio \ Android Studio \ myApp \ build \ intermediates \ dex \ debug --input-list = C: \ Users \ myApp \ Downloads \ Android Studio \ Android Studio \ myApp \ build \ intermediates \ tmp \ dex \ debug \ libraryList.txt Error code: 2 Output: UNCERTAIN TOP LEVEL EXCLUSION: com.android.dex.DexException: several dex files define Landroid / support / v4 / accessibilityservice / AccessibilityServiceInfoCompat $ AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes (DexMerger.javaโˆ—96)

Of course this code solves my problem

configurations { all*.exclude group: 'com.android.support', module: 'support-v4'

but unfortunately does not satisfy me

 dependencies { compile fileTree(include: '*.jar', dir: 'libs') compile 'com.android.support:support-v4:21.+' compile project(':PullToRefreshListFragment') compile project(':validator') compile project(':AndroidBootstrap') compile 'com.google.android.gms:play-services:6.+' compile 'com.android.support:appcompat-v7:21+' compile 'com.github.codechimp-org.apprater:library:1.0.+' compile 'com.sothree.slidinguppanel:library:+' compile 'me.grantland:autofittextview:0.2.+' compile 'io.realm:realm-android:0.71.0' compile ('com.loopj.android:android-async-http:1.4.6') { exclude group: 'com.google.android', module: 'support-v4' } compile('de.keyboardsurfer.android.widget:crouton: 1.8.5@aar ') { exclude group: 'com.google.android', module: 'support-v4' } compile ('io.nlopez.smartlocation:library:2.+') { exclude(group: 'com.google.android', module: 'gms:play-services') } configurations { // all*.exclude group: 'com.android.support', module: 'support-v4' } 

How can I compile a project?

+1
source share
2 answers

library authors should fix them

+3
source

This is apparently a common ADT migration problem for Android. ADT is looking for a copy of android-support-v4.jar in libs / dir, while Android studio has its own internal copy. When you migrate the jar file, it remains in the libs directory, which creates a duplicate jar, most likely an older version. I deleted the jar in the libs directory and the problem was resolved.

+6
source

Source: https://habr.com/ru/post/980393/


All Articles