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

偶尔善良 提交于 2019-12-06 02:44:23

问题


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.


回答1:


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.




回答2:


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

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


来源:https://stackoverflow.com/questions/38456501/how-to-add-external-dependencies-jar-file-to-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!