Added libraries and at the first build, Gradle gives the error:

Error: Error converting bytecode to dex:

Cause: com.android.dex.DexException: Multiple dex files define Lorg / apache / http / ConnectionClosedException;

Error: Execution failed for task ': app: transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.

And in the Gradle Console writes:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ': app: transformClassesWithDexForDebug'.

    com.android.build.api.transform.TransformException: com.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Here are the libraries themselves:

 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile files('libs/httpcore-4.0.1.jar') compile files('libs/httpclient-4.0.1.jar') compile files('libs/gson-2.3.1.jar') compile files('libs/httpmime-4.3.1.jar') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:recyclerview-v7:23.2.1' compile 'org.apache.httpcomponents:httpcore:4.4.5' compile 'br.com.liveo:navigationdrawer-material:2.5.1' compile 'com.mcxiaoke.volley:library:1.0.19' } 

I tried to restart Android Studio, clean the project and recompile, remove httpcore-4.0.1.jar and back synchronize the gradle no changes.

Tell me, please, what's the problem?

    1 answer 1

    HttpClient not supported in SDK 23+ .

    Add the following:

     android { ... useLibrary 'org.apache.http.legacy' } 

    PS Or drop to SDK 22- .