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

I am trying to add external projects (httpmime-4.0-sources.jar) to an android project caused by the android studio popping up errors like

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

I need help.

As a practice, I copied the jar file to the lib folder and added this as a library. But the error does not disappear.

+5
source share
2 answers

Step wise

  • Copy the JAR file to the libs folder
  • Register the module in the build.gradle file, the instructions for which are given in steps 3 to 9
  • Open the file menu and click on the project structure.
  • Now in the Project Structure dialog box, select the application in the module
  • Now click the Dependencies tab in the project structure dialog box.
  • Click the + sign in the right corner.
  • Select "File Dependency" in the list.
  • Select jar file from libs folder
  • Click Apply and Ok
  • Finally click gradle sync button

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

+13
source

First copy your library to the libs folder, and then add this dependency to build.gradle:

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

All Articles