hooloovoo
hooloovoo

Reputation: 825

Conflict with Support Library v4 and Support Library v13 in AndroidStudio

good morning. I'm following thi guide from Android Developers Using ViewPager for Screen Slides http://developer.android.com/training/animation/screen-slide.html I need Support library v4 and support library v13, but when I build project in Android Studio I've this response

 FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/angelo/Tool/android-studio/sdk/build-tools/android-4.4/dx --dex --output /home/angelo/AndroidStudioPojects/Example/app/build/libs/app-debug.dex /home/angelo/AndroidStudioPojects/Example/app/build/classes/debug /home/angelo/AndroidStudioPojects/Example/app/build/dependency-cache/debug /home/angelo/AndroidStudioPojects/Example/app/build/pre-dexed/debug/android-support-v13-d5a7cbb57982899175e7a62be2ac2c67.jar /home/angelo/AndroidStudioPojects/Example/app/build/pre-dexed/debug/android-support-v4-04300e1af199015053fed2602ec8d39c.jar
  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:593)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:551)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:532)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:169)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:187)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

I understand it's a problem due to conflicts of library, but if I remove one of this I can't use some class or method. I necessarily need both.

Upvotes: 1

Views: 4097

Answers (2)

amilcar-sr
amilcar-sr

Reputation: 1060

Yo don't need both libraries, just add:

compile 'com.android.support:support-v13:19.0.1'

In your build.gradle and you'll be fine because support-v13 contains support-v4

Upvotes: 1

I had the same issue. I ccouldn't build the project because of this project, fortunately I am not using the support library in my project so I commented the support library instance on the build.gradle file, then I compiled the project and everything want fine.

Finally, I uncommented that line again and build the project and the issue was gone. That problem is related with including support library twice. Hope this works for you.

Upvotes: 0

Related Questions