Avinash Das
Avinash Das

Reputation: 87

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

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.

Upvotes: 5

Views: 9590

Answers (2)

eLemEnt
eLemEnt

Reputation: 1801

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.

Upvotes: 13

Miguel Benitez
Miguel Benitez

Reputation: 2322

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    ......
}

Upvotes: 10

Related Questions