When building, I get the following message:

Error: Execution failed for task ': app: dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/Romario/Library/Android/sdk/build-tools/21.1.2/dx --dex --no-optimize --output / Users / Romario / Desktop / Yeah / app / build / intermediates / dex / debug - input-list = / Users / Romario / Desktop / Yeah / app / build / intermediates / tmp / dex / debug / inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lorg / jsoup / Connection $ Base; at com.android.dx.merge.DexMerger. (DexMerger.java Down35) at com.android.dx.merge.DexMerger.mergeDexes (DexMerger.java:171) at com.android.dx.merge.DexMerger.merge (DexMerger.java:189) at com.android. dx.command.dexer.Main.mergeLibraryDexBuffers (Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex (Main.java:303) at com.android.dx.command.dexer.Main. run (Main.java:246) at com.android.dx.command.dexer.Main.main (Main.java:215) at com.android.dx.command.Main.main (Main.java:106)

What to do?
In the gradle everything is spelled correctly, the stream is not the main one!

  • show the whole build.gradle. Some libraries may have dependency on another version of jsoup - DeKaNszn
  • android {compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig {applicationId "t t t t t t- proguard-rules.pro '}}} dependencies {compile fileTree (dir:' libs ', include: [' * .jar ']) compile' com.android.support:appcompat-v7:21.0.3 'compile' org. jsoup: jsoup: 1.8.2 '} - PirateNinja
  • What libraries are in the libs folder? - DeKaNszn
  • Only jsoup no more. This is a test project, he uses it only. - PirateNinja
  • jsoup is conflicting in libs and jsoup in compile - DeKaNszn

2 answers 2

Remove jsoup from the libs folder, just specify compile 'org.jsoup:jsoup:1.8.2'

When specified as compile 'group_id:artifact_id:version gradle downloads the library from the Maven repository.
When specified as a compile fileTree(dir: 'libs', include: ['*.jar']) gradle takes all the jars from the folder.
Maven is preferable, but you can only take libraries from a folder.

  • where does the studio know where to get it from? - PirateNinja
  • without this, the application starts and crashes ... - PirateNinja
  • @headfucker updated the answer - DeKaNszn
  • Thanks for the detailed answer! We must now figure out why flies! - PirateNinja

It seems that you have several modules in your project and you have added jsoup to several modules, instead of adding only to the main one.

  • That's just the point, that is used only in one, xs where this error came from. Commented on the compile line - the application is building, but crashes. - PirateNinja
  • And show this compile - anber
  • compile 'org.jsoup: jsoup: 1.8.1' is a string, the rest is native. - PirateNinja