Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

android - multiple dex files define Landroid/support/v4/

I can not compile the project gets the following error compilation:

Error:Execution failed for task ':myApp:dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:Program Files (x86)Androidandroid-studiosdkuild-tools21.0.2dx.bat --dex --output C:UsersAndroid StudioAndroid StudiomyAppuildintermediatesdexdebug --input-list=C:UsersmyAppDownloadsAndroid StudioAndroid StudiomyAppuildintermediatesmpdexdebuglibraryList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)

Of course, this code solve 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 the project?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This seems to be a common ADT to Android studio migration problem. ADT is looking for a copy of android-support-v4.jar in the libs/ dir while Android studio has it's own internal copy. When migrating the jar file is left in the libs dir which creates a duplicate jar most likely an older version. I deleted the jar in the libs dir and problem was solved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...