Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add external dependencies (jar file) to android studio?

I am trying to add external libraries(httpmime-4.0-sources.jar) to android project irked by the fact that android-studio is popping up errors like

  • error: package org.apache.http.entity.mime does not exist
  • error:cannot find symbol class MultipartEntity
  • error: cannot find symbol class HttpMultipartMode

I need help.

As a practice I copied the jar file to the lib folder and added that as a library. But the error does not go away.

like image 718
Avinash Das Avatar asked Jul 19 '16 10:07

Avinash Das


2 Answers

Step wise

  1. Copy JAR File to libs Folder
  2. Register module in build.gradle file, instructions for which are given in steps 3 through 9
  3. Open file menu and click on project structure
  4. Now in Project Structure dialog box select app under module
  5. Now Click on Dependencies tab in project structure dialog
  6. Click on + sign in right side corner
  7. Select File Dependency from list
  8. Select jar file from libs folder
  9. Click apply and Ok
  10. Finally click on sync gradle button

One more thing, check for proxy connection if you are using it.

like image 180
eLemEnt Avatar answered Oct 04 '22 18:10

eLemEnt


First copy your library in libs folder and then add this dependency in build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    ......
}
like image 41
Miguel Benitez Avatar answered Oct 04 '22 19:10

Miguel Benitez